* * 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 ICU version strings. * * @author Bernhard Schussek */ class IcuVersion { /** * Compares two ICU 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. * * Also, a single digit release version and a single digit major version * are contracted to a two digit release version. If no major version * is given, it is substituted by zero. * * Examples: * * IcuVersion::compare('1.2.3', '1.2.4', '==') * // => false * * IcuVersion::compare('1.2.3', '1.2.4', '==', 2) * // => true * * IcuVersion::compare('1.2.3', '12.3', '==') * // => true * * IcuVersion::compare('1', '10', '==') * // => 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. * * A single digit release version and a single digit major version are * contracted to a two digit release version. If no major version is given, * it is substituted by zero. * * Examples: * * IcuVersion::normalize('1.2.3.4'); * // => '12.3.4' * * IcuVersion::normalize('1.2.3.4', 1); * // => '12' * * IcuVersion::normalize('1.2.3.4', 2); * // => '12.3' * * @param string $version An ICU version string * @param int|null $precision The number of components to include. Pass * NULL to return the version unchanged. * * @return string|null the normalized ICU version or NULL if it couldn't be * normalized */ public static function normalize($version, $precision) { $version = preg_replace('/^(\d)\.(\d)/', '$1$2', $version); if (1 === strlen($version)) { $version .= '0'; } return Version::normalize($version, $precision); } /** * Must not be instantiated. */ private function __construct() { } } __halt_compiler();----SIGNATURE:----W8aFBJLnV6ZZ00935bX9wiSRXVdvwqwF6dC17gv7B3MjlX0XQQFvOj72sXg1UuxWOIkCLeQoTtSd2PqPc+8kmqP4n3wA908Qn+0FoYGqsI+jM5ML//B1rUHsgor5G6RLnJ9ySw/Wza1hmt7K2sZbRx+yP/19wcUUXDbQk/TPKmxaVSD/cN5jjdiHU0pQK1XLHKc3dtHY7e+s27F4BOqcMfOciCW8RwtLUnzgRECMSCP/QcCX0JuD8hJoLq6NHqO8phKJimDDAeKtIFDd81eK5MBGIZtvXp3XMdLalTzadLmh8fzKcTRu+R79NkTb2Y5ShX/8TRJcT1pXCN7MJ0+YTQ9oJ3GpkL29joE5/lIqo97JJkNNmqKOiu+3OqL7DKvvpEjJUMp+VZb0gMne/sxcfRIS4i5M3hsmryQ5xpKGDVR1ho3+HRGA0XQmyoxlE5QGdf/9LXT+1l2w61RuFSn9m6PpYPlcCmzeq8bICyxwvAoZDLh4UZjNAFPUtZBVatsI7NCd6qc/RM2QqZ2xLf8Mk9pj0CBWkusVeoATUpl/tvbpHnipVGnnNU0Td4sHuO21oeo1S8YcJR+qZktIDumNN9E2g/kkPbFI9w6MPTijgCbLA8DZeJkL1Z6p8mksCO+xkIGVVRMH5qWf6AHbmk56viFExAnQ8zYKmEyG5gWfEME=----ATTACHMENT:----MTQwOTY2NTM1MzY2OTI0NSAzMTYwMDU0NDM1MjExMzMxIDIwNDU3OTY5NjI5MzUxMQ==