Create Pusher compatible version.

@param  string $version
@return string
491688
public static function getVersion(string $version = ''): string
    {
        if ($version === '') {
            $version = PrettyVersions::getVersion('api-clients/pusher')->getFullVersion();
        }

        list($version, $hash) = explode('@', $version);

        if (strpos($version, 'dev') !== false) {
            return '0.0.1-' . $hash;
        }

        return $version;
    }
444196
public static function isVersion($version){
        $currentVersion = Craft::$app->getVersion();
        $version = explode('.', $version);
        $currentVersion = explode('.', $currentVersion);
        $isVersion = true;
        foreach($version as $key => $value){
            if ((int)$currentVersion[$key] < $version[$key]){ 
                $isVersion = false;
            }
        }
        return $isVersion;
    }
796787
public static function nextSignificantRelease($version) {
        $parsed = explode('.', $version, 3);
        if (count($parsed) > 1) array_pop($parsed);
        $parsed[count($parsed) - 1]++;
        if (count($parsed) === 1) $parsed[] = '0';
        return implode('.', $parsed);
    }
412352
protected function filterProtocolVersion($version)
    {
        if (!is_string($version) || !in_array($version, $this->protocols)) {
            throw new \InvalidArgumentException('The specified protocol is invalid.');
        }

        return $version;
    }
1212628
public function setVersion(string $version)
    {

        if (substr($version, 0, 1) !== '/')
            $version = '/' . $version;

        $this->version = $version;

        return $this;
    }
366227
protected function _getVersionType($version)
    {
        if (strtolower($version) == 'latest') {
            return 'latest';
        }

        $parts = explode('.', $version);
        $count = count($parts);
        if (1 == $count) {
            return 'major';
        }
        if (2 == $count) {
            return 'minor';
        }
        if (3 < $count) {
            throw new Zend_Loader_Exception('Invalid version string provided');
        }
        return 'specific';
    }
867331
public function withProtocolVersion($version)
    {
        if ($this->getProtocolVersion() === $version) {
            return $this;
        }

        $newInstance = clone $this;
        $newInstance->setProtocolVersion($version);
        return $newInstance;
    }
1304998
public static function getVersionCompatible($version)
    {
        // {suffix:weight}
        $suffixes = [
            'dev' => 1, // composer suffix
            'patch' => 2,
            'alpha' => 3,
            'beta' => 4,
            'stable' => 5, // is not a real suffix. use it if suffix is not exists
            'rc' => 6,
        ];

        $reg = '/^v?(?<version>\d+\.\d+\.\d+)(?:-(?<suffix>dev|patch|alpha|beta|rc)(?<suffix_version>\d+)?)?$/i';
        if (!preg_match($reg, $version, $match)) {
            return false;
        }

        // suffix version
        if (isset($match['suffix'])) {
            $suffix = $suffixes[strtolower($match['suffix'])].'.';
            $suffix .= isset($match['suffix_version']) ? (int) $match['suffix_version'] : 1;
        } else {
            $suffix = $suffixes['stable'].'.0';
        }

        return $match['version'].'.'.$suffix;
    }
730215
public function format(Version $version)
    {
        if (preg_match('/^(\d+)-g([a-fA-F0-9]{7,40})(-dirty)?$/', $version->getPreRelease(), $matches)) {
            if ((int) $matches[1] != 0) {
                // we are not on TAG commit, add "dev" and git commit hash as pre release part
                $version = $version->withPreRelease(array('dev', $matches[2]));
            } else {
                $version = $version->withPreRelease(array());
            }
        }

        if (preg_match('/^(.*)-(\d+)-g([a-fA-F0-9]{7,40})(-dirty)?$/', $version->getPreRelease(), $matches)) {
            if ((int) $matches[2] != 0) {
                // we are not on TAG commit, add "dev" and git commit hash as pre release part
                if (empty($matches[1])) {
                    $version = $version->withPreRelease(array('dev', $matches[3]));
                } else {
                    $version = $version->withPreRelease(array_merge(explode('.', trim($matches[1], '-')), array('dev', $matches[3])));
                }
            } else {
                if (empty($matches[1])) {
                    $version = $version->withPreRelease(array());
                } else {
                    $version = $version->withPreRelease(trim($matches[1], '-'));
                }
            }
        }

        return $version;
    }
728224
static public function appendPatchVersion($version)
    {
        $shortKnownVersions = array('2.0', '2.1', '2.2');
        if (in_array($version, $shortKnownVersions) === true) {
            $version = $version . '.0';
        }
        
        return $version;
    }
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 '';
    }
867841
public function getDetectedVersion($version)
    {
        return isset($this->detectedVersions[$version]) ? $this->detectedVersions[$version] : null;
    }
1042524
public function setVersion($version)
    {
        $availableVersions = ['v1'];

        if (in_array($version, $availableVersions)) {
            $this->version = $version;

            $this->initConfiguration();

            return $this;
        }

        throw new InvalidArgument(
            'Invalid Consumer API version, available versions are: ' . implode(', ', $availableVersions)
        );
    }
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;
    }
957215
protected function createConstraints($version)
    {
        switch ($version) {
            case self::VERSION_CURRENT:
            case self::VERSION_DRAFT_4:
                return $this->createBuiltInConstraints(
                    array_merge(
                        self::$commonConstraints,
                        self::$draft4Constraints
                    )
                );
            default:
                throw new UnsupportedVersionException(
                    "Schema version '{$version}' not supported"
                );
        }
    }
1338915
public static function createFrame($version)
    {
        $width = self::$capacity[$version][Constants::QRCAP_WIDTH];
        $frameLine = str_repeat ("\0", $width);
        $frame = array_fill(0, $width, $frameLine);

        // Finder pattern
        self::putFinderPattern($frame, 0, 0);
        self::putFinderPattern($frame, $width - 7, 0);
        self::putFinderPattern($frame, 0, $width - 7);

        // Separator
        $yOffset = $width - 7;

        for($y=0; $y<7; $y++) {
            $frame[$y][7] = "\xc0";
            $frame[$y][$width - 8] = "\xc0";
            $frame[$yOffset][7] = "\xc0";
            $yOffset++;
        }

        $setPattern = str_repeat("\xc0", 8);

        QRstr::set($frame, 0, 7, $setPattern);
        QRstr::set($frame, $width-8, 7, $setPattern);
        QRstr::set($frame, 0, $width - 8, $setPattern);

        // Format info
        $setPattern = str_repeat("\x84", 9);
        QRstr::set($frame, 0, 8, $setPattern);
        QRstr::set($frame, $width - 8, 8, $setPattern, 8);

        $yOffset = $width - 8;

        for($y=0; $y<8; $y++,$yOffset++) {
            $frame[$y][8] = "\x84";
            $frame[$yOffset][8] = "\x84";
        }

        // Timing pattern

        for($i=1; $i<$width-15; $i++) {
            $frame[6][7+$i] = chr(0x90 | ($i & 1));
            $frame[7+$i][6] = chr(0x90 | ($i & 1));
        }

        // Alignment pattern
        self::putAlignmentPattern($version, $frame, $width);

        // Version information
        if($version >= 7) {
            $vinf = self::getVersionPattern($version);

            $v = $vinf;

            for($x=0; $x<6; $x++) {
                for($y=0; $y<3; $y++) {
                    $frame[($width - 11)+$y][$x] = chr(0x88 | ($v & 1));
                    $v = $v >> 1;
                }
            }

            $v = $vinf;
            for($y=0; $y<6; $y++) {
                for($x=0; $x<3; $x++) {
                    $frame[$y][$x+($width - 11)] = chr(0x88 | ($v & 1));
                    $v = $v >> 1;
                }
            }
        }

        // and a little bit...
        $frame[$width - 8][8] = "\x81";

        return $frame;
    }
1202700
public static function fromExtendedKeyVersion($version)
    {
        switch ($version) {
            case MainNet::HD_PRIVATE_KEY_ID:
            case MainNet::HD_PUBLIC_KEY_ID:
                return MainNet::instance();
            case TestNet::HD_PRIVATE_KEY_ID:
            case TestNet::HD_PUBLIC_KEY_ID:
                return TestNet::instance();
            default:
                throw new \InvalidArgumentException('Unknown extended key version.');
                break;
        }
    }