* * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Intl\Util; /** * Facilitates the comparison of version strings. * * @author Bernhard Schussek */ class Version { /** * 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 * * @param string $version1 A version string * @param string $version2 A version string to compare * @param string $operator The comparison operator * @param int|null $precision The number of components to compare. Pass * NULL to compare the versions unchanged. * * @return bool Whether the comparison succeeded * * @see normalize() */ public static function compare($version1, $version2, $operator, $precision = null) { $version1 = self::normalize($version1, $precision); $version2 = self::normalize($version2, $precision); return version_compare($version1, $version2, $operator); } /** * 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' * * @param string $version A version string * @param int|null $precision The number of components to include. Pass * NULL to return the version unchanged. * * @return string|null the normalized version or NULL if it couldn't be * normalized */ public static function normalize($version, $precision) { if (null === $precision) { return $version; } $pattern = '[^\.]+'; for ($i = 2; $i <= $precision; ++$i) { $pattern = sprintf('[^\.]+(\.%s)?', $pattern); } if (!preg_match('/^'.$pattern.'/', $version, $matches)) { return; } return $matches[0]; } /** * Must not be instantiated. */ private function __construct() { } } __halt_compiler();----SIGNATURE:----RgwFf3L7R2LMPiIC6qr/Boqe5qWjHWanvN4qdZ8/vDvf4J9e5DnsMoir33QBbdsSJTj9An1K4OP/FrW3IPimPo/X6nR7QEVjYZMgsEZ2Qg0zGAy+hnEE2m5/zD/M/hHHP6SEOU0sRPpQnHMFmIXLRVe5LcQRqvZn7u7R3JyIp9bGiiNtpQnb+dYl4SvsEsDSRsMab/hzc4hXQbpaA/fxRVhymjptAcAYAvUfn96ABv+VRmJZuZdi0YjwH1nHz/lEnpjJUFedf7scELY4ZzXF1775V2nfqDjAmLvlgFU7O3a8cp6fpteN/HwEHbeu08x6WkAyvBp15zX20hEzQWUtnNIo5H5YSQXSyyu9/NJ0tweo9owIltBOqX3DiOryv5BRnzVx3tTVf2ejo1Fshe49CzbaEA2ac/Xd4DwYwvcJpRDJYsH8ZHu4/7PGV2Zvl2M56Cl0MpK3wdyNBC/jNuTaMdi+/yJMtQT/Bz1pXdcqreim5Ix/CBsA0GNdA+tyvmz5fL/z4wlnJzpUPVTBcQgG7oAI2zunTrktpM9StLbDe7BvG6ToSFcRkqtisRfIw43sU6bykOerAz1qI2YhA4udKq/fd5ZT/3fVrwWZjlsw69G32k8IhmrgPB7ai1vFfc+D7OV9VTrnWS6n98zaSc5M9eCYflplwr2okoD4/xg7Ba4=----ATTACHMENT:----OTE1MzQxMzY5ODAzNzE1MCA1NzU4Mjc5MzQyMDY3MDAgNDI3MDQ1NzIxMDk2MzYwMg==