PhilippBaschke\ACFProInstaller\Plugin::validateVersion PHP Method

validateVersion() protected method

The url to download the code for the package only works with exact version numbers with 3 or 4 digits: e.g. 1.2.3 or 1.2.3.4
protected validateVersion ( string $version ) : string
$version string The version that should be validated
return string The valid version
    protected function validateVersion($version)
    {
        // \A = start of string, \Z = end of string
        // See: http://stackoverflow.com/a/34994075
        $major_minor_patch_optional = '/\\A\\d\\.\\d\\.\\d{1,2}(?:\\.\\d)?\\Z/';
        if (!preg_match($major_minor_patch_optional, $version)) {
            throw new \UnexpectedValueException('The version constraint of ' . self::ACF_PRO_PACKAGE_NAME . ' should be exact (with 3 or 4 digits). ' . 'Invalid version string "' . $version . '"');
        }
        return $version;
    }