Returns the components of a Version instance.

@param Version $version A version.

@return array The components.
498408
public static function toComponents(Version $version)
    {
        return array(
            Parser::MAJOR => $version->getMajor(),
            Parser::MINOR => $version->getMinor(),
            Parser::PATCH => $version->getPatch(),
            Parser::PRE_RELEASE => $version->getPreRelease(),
            Parser::BUILD => $version->getBuild()
        );
    }
1116334
public static function toComponents($version)
    {
        if (!Validator::isVersion($version)) {
            throw new InvalidStringRepresentationException($version);
        }

        if (false !== strpos($version, '+')) {
            list($version, $build) = explode('+', $version);

            $build = explode('.', $build);
        }

        if (false !== strpos($version, '-')) {
            list($version, $pre) = explode('-', $version);

            $pre = explode('.', $pre);
        }

        list(
            $major,
            $minor,
            $patch
        ) = explode('.', $version);

        return array(
            self::MAJOR => intval($major),
            self::MINOR => intval($minor),
            self::PATCH => intval($patch),
            self::PRE_RELEASE => isset($pre) ? $pre : array(),
            self::BUILD => isset($build) ? $build : array(),
        );
    }
215653
public function getServiceUrl($version = null)
    {
        if ($version) {
            return $this->getWebserviceUrl() . $this->getServicePath($version);
        } else {
            return $this->getWebserviceUrl() . $this->getServicePath();
        }
    }
359995
private function getVersionNumbers(array $versions): array
    {
        $versionNumbers = array_column($versions, 'versionNo');

        return array_combine($versionNumbers, array_fill_keys($versionNumbers, false));
    }
873590
public function getVersionedContent($version)
    {
        $versions = $this->getVersions();
        if (!in_array($version, $versions, true)) {
            throw new \UnexpectedValueException("Invalid log entry $version for {$this->path}.");
        }

        if (($content = \Arbit\VCSWrapper\Cache\Manager::get($this->path, $version, 'content')) === false) {
            // Refetch the basic content information, and cache it.
            $process = new \Arbit\VCSWrapper\CvsCli\Process();
            $process
                ->workingDirectory($this->root)
                ->redirect(\Arbit\VCSWrapper\CvsCli\Process::STDERR, \Arbit\VCSWrapper\CvsCli\Process::STDOUT)
                ->argument('update')
                ->argument('-p')
                ->argument('-r')
                ->argument($version)
                ->argument('.' . $this->path)
                ->execute();

            $output  = $process->stdoutOutput;
            $content = ltrim(substr($output, strpos($output, '***************') + 15));
            \Arbit\VCSWrapper\Cache\Manager::cache($this->path, $version, 'content', $content);
        }

        return $content;
    }
376688
public static function parseVersion($version)
    {
        if (preg_match('#^(\d+)\.(\d+)\.(\d+)(\-([\w.\-]+)|)$#', $version, $match)) {
            return (object) array(
                'major' => $match[1],
                'minor' => $match[2],
                'patch' => $match[3],
                'extra' => empty($match[5]) ? null : $match[5]
            );
        }

        return false;
    }
57981
protected static function cleanExtraVersion($version)
    {
        $pos = strpos($version, '-');

        if (false !== $pos) {
            $version = substr($version, 0, $pos);
        }

        return $version;
    }
1016471
public function importVersion($version)
    {
        return $this
            ->setMajor($version->getMajor())
            ->setMinor($version->getMinor())
            ->setPatch($version->getPatch())
            ->setPreRelease($version->getPreRelease())
            ->setBuild($version->getBuild());
    }
858294
protected function getPackageKeyFromMigrationVersion(Version $version)
    {
        $sortedAvailablePackages = $this->packageManager->getAvailablePackages();
        usort($sortedAvailablePackages, function (PackageInterface $packageOne, PackageInterface $packageTwo) {
            return strlen($packageTwo->getPackagePath()) - strlen($packageOne->getPackagePath());
        });

        $reflectedClass = new \ReflectionClass($version->getMigration());
        $classPathAndFilename = Files::getUnixStylePath($reflectedClass->getFileName());

        /** @var $package PackageInterface */
        foreach ($sortedAvailablePackages as $package) {
            $packagePath = Files::getUnixStylePath($package->getPackagePath());
            if (strpos($classPathAndFilename, $packagePath) === 0) {
                return $package->getPackageKey();
            }
        }

        return '';
    }
774975
protected function parseVersion($version, $prefix)
    {
        $response = [];

        if (preg_match('%(?<major>\d+)((\.(?<minor>\d+)((\.(?<patch>\d+))|$))|$)%', $version, $match)) {
            $pieces = [];

            foreach ($match as $key => $value) {
                if ($key === 'major' || $key === 'minor' || $key === 'patch') {
                    $pieces[] = $response[$prefix . 'Version' . ucfirst($key)] = (int) $value;
                }
            }

            if ( ! empty($pieces)) {
                $response[$prefix . 'Version'] = implode('.', $pieces);
            }
        }

        return $response;
    }
1128253
public function migrationClass($group, $version)
    {
        $versions = array_get($this->migrations, $group, []);

        return array_get($versions, $version, null);
    }
1121556
public function getComponents($component = null)
    {
        if (is_null($component)) {
            return $this->components;
        }

        $this->validateComponentExists($component);

        return $this->components[$component];
    }
1175013
public static function getStaticItems( string $locale = 'en_US', string $version = null ) : array
	{
		$url = self::getStaticDataFileUrl(self::STATIC_ITEMS, null, $locale, $version);
		return self::loadStaticData($url);
	}
1178668
public function getVersion(string $id, int $version = 1): array
    {
        $this->setFile($id);
        $id = Check::name(pathinfo($id, PATHINFO_FILENAME));
        try {
            $fileName = str_replace("{$id}.json", "version/{$id}#{$version}.json", $this->file);
            if (file_exists($fileName))
                return array_merge(["id" => $id], json_decode(file_get_contents($fileName), true));
        } catch (\Exception $e) {
            return [];
        }
        return [];
    }
867841
public function getDetectedVersion($version)
    {
        return isset($this->detectedVersions[$version]) ? $this->detectedVersions[$version] : null;
    }
1334563
protected function getExplicitStability($version)
    {
        $found   = null;
        $pattern = $this->getPattern();

        foreach (static::splitConstraints($version) as $constraint) {
            if ( ! preg_match($pattern, $constraint, $match)) {
                continue;
            }

            $stability = $this->getStabilityInteger($match[1]);
            $found     = max($stability, $found);
        }

        return $found;
    }
1257545
private static function fetchProtocolVersion(string $version): string
    {
        $v = substr($version, 5);

        if ($v === '2.0') {
            return '2';
        }

        // Fallback for values outside of valid protocol versions
        if (!in_array($v, static::$allowedVersions, true)) {
            return '1.1';
        }

        return $v;
    }