function Version::ensureVersionStringIsValid
Parameters
string $version:
Throws
1 call to Version::ensureVersionStringIsValid()
- Version::__construct in vendor/
phar-io/ version/ src/ Version.php
File
-
vendor/
phar-io/ version/ src/ Version.php, line 182
Class
Namespace
PharIo\VersionCode
private function ensureVersionStringIsValid($version) : void {
$regex = '/^v?
(?P<Major>0|[1-9]\\d*)
\\.
(?P<Minor>0|[1-9]\\d*)
(\\.
(?P<Patch>0|[1-9]\\d*)
)?
(?:
-
(?<PreReleaseSuffix>(?:(dev|beta|b|rc|alpha|a|patch|p|pl)\\.?\\d*))
)?
(?:
\\+
(?P<BuildMetadata>[0-9a-zA-Z-]+(?:\\.[0-9a-zA-Z-@]+)*)
)?
$/xi';
if (\preg_match($regex, $version, $matches) !== 1) {
throw new InvalidVersionException(\sprintf("Version string '%s' does not follow SemVer semantics", $version));
}
$this->parseVersion($matches);
}