Parse a string into Versionable properties

@throws InvalidArgumentException

@param  string             $string
@param  string             $className
@return VersionableVersion
198812
public static function parse($string, $className)
    {
        // Sanity check
        if (substr_count($string, '.') !== 2) {
            throw new InvalidArgumentException(
                'part "' . $string . '" can not be parsed into a SemVer'
                . ' major.minor.patch version'
            );
        }

        // Simple explode will do here
        $parts = explode('.', $string);

        // Instantiate
        $versionable = new $className;

        // Sanity check of class type
        if (!($versionable instanceof VersionableVersion)) {
            throw new InvalidArgumentException(
                '"' . $className . '" is not Versionable'
            );
        }

        // Versionable parts
        $versionable
            ->setMajor((int) $parts[0])
            ->setMinor((int) $parts[1])
            ->setPatch((int) $parts[2]);

        return $versionable;
    }
804488
public static function fromString($string)
    {
        $string = trim($string);
        if (!$string) {
            throw new \InvalidArgumentException('Empty attribute path');
        }

        $colonPos = strrpos($string, ':');
        if ($colonPos !== false) {
            $schema = substr($string, 0, $colonPos);
            $path = substr($string, $colonPos + 1);
        } else {
            $schema = null;
            $path = $string;
        }

        $parts = explode('.', $path);
        $attributePath = new static();
        $attributePath->schema = $schema;
        foreach ($parts as $part) {
            $attributePath->add($part);
        }

        return $attributePath;
    }
288327
protected function withString ($string, $name = 'query')
    {
        if (!is_string($string) && !method_exists($string, '__toString')) {
            throw new InvalidArgumentException('Uri fragment must be a string');
        }
        $string = ltrim((string) $string, '#');
        $clone = clone $this;
        $clone->$name = $this->filterQuery($string);

        return $clone;
    }
1121268
public function parseString($string)
    {
        $value = $this->getParser()->parse($string);

        if ($this->trimArrayValues && is_array($value)) {
            return $this->trimArray($value);
        }

        return $value;
    }
853367
private function getPSRCompatibleClassName($string)
    {
        $className = '';
        $arr = explode('_', $string);

        foreach ($arr as $key => $value) {
            $className .= ucfirst(strtolower($value));
        }

        return $className;
    }
82254
protected function parseCsvString($str)
    {
        if (! isset($this->optionsIndexMap) || ! is_array($this->optionsIndexMap) || empty($this->optionsIndexMap)) {
            throw new \InvalidArgumentException(sprintf(
                'Class %s is missing the `optionsIndexMap` property',
                get_class($this)
            ));
        }

        $options = explode(',', $str);
        $result  = array();
        foreach ($options as $k => $v) {
            if (! isset($this->optionsIndexMap[$k])) {
                throw new \InvalidArgumentException(sprintf(
                    'Class %s does not have the index %d configured in the `optionsIndexMap` property',
                    get_class($this),
                    $k
                ));
            }
            $result[$this->optionsIndexMap[$k]] = $v;
        }

        return $this->convertBooleanStrings($result);
    }
221075
static function Parse($string) {
        $result = null;
        if (!self::TryParse($string, $result)) {
            throw new \InvalidArgumentException("'$string' could not be converted to a number");
        }
        return $result;
    }
567230
public function type(string $classType)
    {
        $baseType = $this->class ? $this->class->getClassName() : TypedObject::class;
        if (!is_a($classType, $baseType, true)) {
            throw InvalidArgumentException::format(
                'Invalid call to %s: class type must be an subclass of %s, %s given',
                __METHOD__, $baseType, $classType
            );
        }

        /** @var TypedObject $classType */
        $this->class = $classType::definition();
    }
908191
public static function matchSemVer($string)
    {
        // Array of matches for PCRE
        $matches = array();

        // Match the possible parts of a SemVer
        $matched = preg_match(
            self::$version,
            $string,
            $matches
        );

        // No match, invalid
        if (!$matched) {
            throw new InvalidArgumentException(
                '"' . $string . '" is not a valid SemVer'
            );
        }

        // Return matched array
        return $matches;
    }
497768
public function parse($className) {


        try {
            $class = new \ReflectionClass($className);
        } catch (\ReflectionException $e) {
            return new ClassAnnotations($className, array(), array(), array());
        }


        // get the master annotations
        $classComment = $class->getDocComment();
        $classAnnotations = $this->getCommentAnnotations($classComment);
        $classAnnotations["comment"] = array(new Annotation("comment", $this->cleanComment($classComment)));


        $fieldAnnotations = array();
        $properties = $class->getProperties();

        foreach ($properties as $property) {

            if ($property->isStatic())
                continue;


            $fieldComment = $this->getCommentAnnotations($property->getDocComment());
            $fieldAnnotations[$property->getName()] = $fieldComment;

            $fieldAnnotations[$property->getName()]["comment"] = array(new Annotation("comment", $this->cleanComment($property->getDocComment())));

        }


        $methodAnnotations = array();
        $methods = $class->getMethods();

        foreach ($methods as $method) {

            if ($method->isStatic() || $method->isPrivate() || $method->isProtected())
                continue;
            $methodComment = $this->getCommentAnnotations($method->getDocComment());
            $methodAnnotations[$method->getName()] = $methodComment;

            if ($method->getDeclaringClass()->getName() != $className) {
                $methodAnnotations[$method->getName()]["inherited"] = 1;
            }

            $methodAnnotations[$method->getName()]["comment"] = array(new Annotation("comment", $this->cleanComment($method->getDocComment())));


        }


        return new ClassAnnotations($className, $classAnnotations, $fieldAnnotations, $methodAnnotations);

    }
152619
public static function fromString($className)
    {
        $atoms = explode(static::NAMESPACE_SEPARATOR, $className);
        $isAbsolute = false;
        if ('' === $atoms[0]) {
            $isAbsolute = true;
            array_shift($atoms);
        }

        return static::fromAtoms($atoms, $isAbsolute);
    }
57068
private function getReflectionClass($className) : ReflectionClass
    {
        if (! class_exists($className)) {
            throw InvalidArgumentException::fromNonExistingClass($className);
        }

        $reflection = new ReflectionClass($className);

        if ($reflection->isAbstract()) {
            throw InvalidArgumentException::fromAbstractClass($reflection);
        }

        return $reflection;
    }
811545
private function getByClassName($className)
    {
        if ($className === '') {
            throw new \InvalidArgumentException('$className must not be empty.', 1331488868);
        }
        $unifiedClassName = self::unifyClassName($className);

        if (!isset($this->mappers[$unifiedClassName])) {
            if (!class_exists($className, true)) {
                throw new \InvalidArgumentException(
                    'No mapper class "' . $className . '" could be found.'
                );
            }

            /** @var \Tx_Oelib_DataMapper $mapper */
            $mapper = GeneralUtility::makeInstance($unifiedClassName);
            $this->mappers[$unifiedClassName] = $mapper;
        } else {
            /** @var \Tx_Oelib_DataMapper $mapper */
            $mapper = $this->mappers[$unifiedClassName];
        }

        if ($this->testingMode) {
            $mapper->setTestingFramework($this->testingFramework);
        }
        if ($this->denyDatabaseAccess) {
            $mapper->disableDatabaseAccess();
        }

        return $mapper;
    }
410418
public static Object[] parseVersionString(String versionString) {
        if (versionString == null) {
            return null;
        }

        // check for whitespace
        if (versionString.matches("\\s")) {
            return null;
        }

        // split on the dots
        String[] split = versionString.split("\\.");
        if (split.length == 0) {
            return null;
        }

        Object[] v = new Object[split.length];
        int i = 0;
        for (String s : split) {
            try {
                v[i] = Integer.parseInt(s);
            } catch (NumberFormatException e) {
                v[i] = s;
            }
            i++;
        }

        // check for a numeric beginning
        if (v[0] instanceof Integer) {
            return v;
        }
        else {
            return null;
        }
    }
292358
public static function validatePascalCase($string)
    {
        if (SetupHelper::getPascalCase($string) === $string) {
            return (string)$string;
        }

        throw new InvalidArgumentException(
            sprintf(
                'Provided string "%1$s" was not in PascalCase.',
                $string
            )
        );
    }
1152722
public function contains($className)
    {
        if (!is_string($className)) {
            throw new InvalidArgumentException(sprintf('%s expects parameter 1 to be string, %s given', __METHOD__, (is_object($className) ? get_class($className) : gettype($className))));
        }

        $this->parseClassAttribute();

        return in_array($className, $this->classes, true);
    }
1258744
public static function parse($string)
    {
        // Explode over '.'
        $parts = explode('.', $string);

        // Instantiate
        $buildVersion = new BuildVersion;

        // No parts is no build?
        if (count($parts) === 0) {
            return $buildVersion;
        }

        // Discard "build" string should it prepend the build
        if ($parts[0] === 'build') {
            array_shift($parts);
        }

        // If the first part is a number it's the build number
        if (isset($parts[0]) && is_numeric($parts[0])) {
            $buildVersion->setNumber(
                (int) array_shift($parts)
            );
        }

        // All other parts are custom and can simply be put on a stack
        foreach ($parts as $part) {
            $buildVersion->addPart($part);
        }

        // Return
        return $buildVersion;
    }