Fetches the latest version. If you do not want the latest version, specify one and pass it.

@param string $version

@throws \Exception

@return mixed
483463
public function fetch($version = '')
    {
        if (($releaseCollection = $this->getPackageReleases())->isEmpty()) {
            throw new \Exception('Cannot find a release to update. Please check the repository you\'re pulling from');
        }

        $release = $releaseCollection->first();
        $storagePath = $this->config['download_path'];

        if (! File::exists($storagePath)) {
            File::makeDirectory($storagePath, 493, true, true);
        }

        if (! $version) {
            $release = $releaseCollection->where('name', $version)->first();
            if (! $release) {
                throw new \Exception('Given version was not found in release list.');
            }
        }

        $versionName = $this->prepend.$release->name.$this->append;
        $storageFilename = $versionName.'.zip';

        if (! $this->isSourceAlreadyFetched($release->name)) {
            $storageFile = $storagePath.'/'.$storageFilename;
            $this->downloadRelease($this->client, $release->zipball_url, $storageFile);
            $this->unzipArchive($storageFile, $storagePath.'/'.$versionName);
        }
    }
931656
protected function getVersion($version)
    {
        if (!$this->{$version.'Version'}) {
            $revisioned = get_class($this->revisioned);

            $revision = new $revisioned();
            $revision->setRawAttributes($this->{$version});

            $this->{$version.'Version'} = $revision;
        }

        return $this->{$version.'Version'};
    }
1283063
public static function fromString(string $version) : Version
    {
        $patternMajor      = '(?P<major>[0-9]+)';
        $patternMinor      = '(?P<minor>[0-9]+)';
        $patternPatch      = '(?P<patch>[0-9]+)';
        $patternPreRelease = '(?:-(?P<prerelease>(?:[0-9A-Za-z-]+\.)*(?:[0-9A-Za-z-]+)))?';
        $patternBuild      = '(?:\+(?P<build>(?:[0-9A-Za-z-]+\.)*(?:[0-9A-Za-z-]+)))?';

        $pattern = '#^'.$patternMajor.'\.'.$patternMinor.'\.'.$patternPatch.$patternPreRelease.$patternBuild.'$#';
        if (!preg_match($pattern, $version, $matches)) {
            throw new InvalidArgumentException(sprintf('The string "%s" does not look like a version.', $version));
        }

        return new static(
            (int) $matches['major'],
            (int) $matches['minor'],
            (int) $matches['patch'],
            $matches['prerelease'] ?? '',
            $matches['build'] ?? ''
        );
    }
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;
    }
165808
public static function compare($version)
    {
        $version = strtolower($version);
        $version = preg_replace('/(\d)pr(\d?)/', '$1a$2', $version);
        return version_compare($version, strtolower(static::VERSION));
    }
1211450
public function withProtocolVersion($version)
    {
        $request = clone $this;
        if (method_exists($request, 'setProtocolVersion')) {
            $request->setProtocolVersion($version);
        } else {
            $request->server->set('SERVER_PROTOCOL', $version);
        }

        return $request;
    }
838977
public static function get_by_version($version) {
		$migrations = self::get_all();

		if (strpos($version, '/') === false) {
			$version = 'project/' . $version;
		}

		list($package, $version) = explode('/', $version);
		$migrations = \Skeleton\Database\Migration::get_between_versions($package);

		foreach ($migrations as $migration) {
			if (preg_match('@\\\\([\w]+)$@', get_class($migration), $matches)) {
				$classname = $matches[1];
			} else {
				$classname = get_class($migration);
			}
			if ($version == $classname) {
				return $migration;
			}

		}

		throw new \Exception('The specified version does not exists.');
	}
1103136
protected function getVersion()
    {
        static $version;
        if (!$version) {
            $version = false;
            $string = $this->execute(['--version'], false);
            if ($string && preg_match('/(^| )([0-9]+[^ ]*)/', $string, $matches)) {
                $version = $matches[2];
            }
        }

        return $version;
    }
1120107
protected function version()
    {
        $version = $this->argument('version');

        if (!$version) {
            return $this->latestVersion();
        }

        if (!ctype_digit($version)) {
            return $version;
        }

        $version = (int) $version;

        if ($version < 70) {
            return $this->legacyVersion($version);
        }

        $url = sprintf(static::$versionUrl, $version);

        return trim(file_get_contents($url));
    }
727160
public function getVersion()
    {
        $composer = $this->loadJsonFileFromRoot("composer.json");

        if (!isset($composer->version)){
            throw new \Exception("composer.json does not contain a version");
        }

        return $composer->version;
    }
284863
public function getVersion()
    {
        if (isset($this->version)) {
            return (string)$this->version;
        } else {
            OsDetector::detect($this, $this->getUserAgent());

            return (string)$this->version;
        }
    }
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;
    }
66402
public function fetch($version = '')
    {
        $response = $this->getRepositoryReleases();
        $releaseCollection = collect(\GuzzleHttp\json_decode($response->getBody()));

        if ($releaseCollection->isEmpty()) {
            throw new \Exception('Cannot find a release to update. Please check the repository you\'re pulling from');
        }

        $release = $releaseCollection->first();

        $storagePath = $this->config['download_path'];

        if (! File::exists($storagePath)) {
            File::makeDirectory($storagePath, 493, true, true);
        }

        if (! empty($version)) {
            $release = $releaseCollection->where('name', $version)->first();
        }

        $storageFilename = "{$release->name}.zip";

        if (! $this->isSourceAlreadyFetched($release->name)) {
            $storageFile = $storagePath.$storageFilename;
            $this->downloadRelease($this->client, $release->zipball_url, $storageFile);

            $this->unzipArchive($storageFile, $storagePath);
            $this->createReleaseFolder($storagePath, $release->name);
        }
    }
293033
public function fetch($identifier, $version=null)
    {
        $portableElements = $this->getAllVersions($identifier);

        // No version, return latest version
        if (is_null($version)) {
            $this->krsortByVersion($portableElements);
            return $this->getModel()->createDataObject(reset($portableElements));
        }

        // Version is set, return associated record
        if (isset($portableElements[$version])) {
            return $this->getModel()->createDataObject($portableElements[$version]);
        }

        // Version is set, no record found
        throw new PortableElementNotFoundException(
            $this->getModel()->getId() . ' with identifier ' . $identifier. ' found, '
            . 'but version "' . $version . '" does not exist.'
        );
    }
1231672
public function getFileVersion($version)
    {
        /** @var FileVersion $fileVersion */
        foreach ($this->fileVersions as $fileVersion) {
            if ($fileVersion->getVersion() === $version) {
                return $fileVersion;
            }
        }

        return null;
    }
1278880
public function version($version = null)
    {
        if (func_num_args() === 0) {
            return $this->_version;
        }
        $this->_version = $version;
        return $this;
    }
253399
public function setVersion($version)
    {
        if ($version == self::VERSION_3 || $version == self::VERSION_3_1_1) {
            $this->version = $version;
        } else {
            throw new Exception('Invalid version');
        }
    }