PhantomInstaller\Installer::getVersion PHP Method

getVersion() public method

Firstly, we search for a version number in the local repository, secondly, in the root package. A version specification of "dev-master#" is disallowed.
public getVersion ( ) : string
return string $version Version
    public function getVersion()
    {
        $composer = $this->getComposer();
        // try getting the version from the local repository
        $packages = $composer->getRepositoryManager()->getLocalRepository()->getCanonicalPackages();
        foreach ($packages as $package) {
            if ($package->getName() === static::PACKAGE_NAME) {
                $version = $package->getPrettyVersion();
                break;
            }
        }
        // let's take a look at the aliases
        $aliases = $composer->getLocker()->getAliases();
        foreach ($aliases as $idx => $alias) {
            if ($alias['package'] === static::PACKAGE_NAME) {
                return $alias['alias'];
            }
        }
        // fallback to the hardcoded latest version, if "dev-master" was set
        if ($version === 'dev-master') {
            return $this->getLatestPhantomJsVersion();
        }
        // grab version from commit-reference, e.g. "dev-master#<commit-ref> as version"
        if (preg_match('/dev-master#(?:.*)(\\d.\\d.\\d)/i', $version, $matches)) {
            return $matches[1];
        }
        // grab version from a Composer patch version tag with a patch level, like "1.9.8-p02"
        if (preg_match('/(\\d.\\d.\\d)(?:(?:-p\\d{2})?)/i', $version, $matches)) {
            return $matches[1];
        }
        // let's take a look at the root package
        if (!empty($version)) {
            $version = $this->getRequiredVersion($composer->getPackage());
        }
        return $version;
    }