class Version
Facilitates the comparison of version strings.
static bool | compare(string $version1, string $version2, string $operator, int|null $precision = null) Compares two versions with an operator. | |
static string|null | normalize(string $version, int|null $precision) Normalizes a version string to the number of components given in the parameter $precision. |
Compares two versions with an operator.
This method is identical to {@link version_compare()}, except that you can pass the number of regarded version components in the last argument $precision.
Examples:
Version::compare('1.2.3', '1.2.4', '==')
// => false
Version::compare('1.2.3', '1.2.4', '==', 2)
// => true
string | $version1 | A version string |
string | $version2 | A version string to compare |
string | $operator | The comparison operator |
int|null | $precision | The number of components to compare. Pass NULL to compare the versions unchanged. |
bool | Whether the comparison succeeded |
normalize() |
Normalizes a version string to the number of components given in the parameter $precision.
Examples:
Version::normalize('1.2.3', 1);
// => '1'
Version::normalize('1.2.3', 2);
// => '1.2'
string | $version | A version string |
int|null | $precision | The number of components to include. Pass NULL to return the version unchanged. |
string|null | the normalized version or NULL if it couldn't be normalized |
© 2004–2017 Fabien Potencier
Licensed under the MIT License.
https://api.symfony.com/4.1/Symfony/Component/Intl/Util/Version.html