|
|
|
@ -1,7 +1,7 @@
|
|
|
|
|
<?php
|
|
|
|
|
// Version.php
|
|
|
|
|
// Created: 2021-04-29
|
|
|
|
|
// Updated: 2022-02-27
|
|
|
|
|
// Updated: 2023-01-01
|
|
|
|
|
|
|
|
|
|
namespace Index;
|
|
|
|
|
|
|
|
|
@ -234,6 +234,12 @@ class Version implements Stringable, IComparable, IEquatable {
|
|
|
|
|
if(!preg_match('#^v?(?P<major>0|[1-9]\d*)\.(?P<minor>0|[1-9]\d*)\.(?P<patch>0|[1-9]\d*)(?:-(?P<prerelease>(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+(?P<build>[0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$#', $versionString, $matches))
|
|
|
|
|
throw new InvalidArgumentException('$versionString is not a valid version string.');
|
|
|
|
|
|
|
|
|
|
return new Version($matches['major'], $matches['minor'], $matches['patch'], $matches['prerelease'] ?? '', $matches['build'] ?? '');
|
|
|
|
|
return new Version(
|
|
|
|
|
(int)$matches['major'],
|
|
|
|
|
(int)$matches['minor'],
|
|
|
|
|
(int)$matches['patch'],
|
|
|
|
|
$matches['prerelease'] ?? '',
|
|
|
|
|
$matches['build'] ?? ''
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|