* * 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:----RcUdJ5PBzr2AKVhQlrp3gwZXcjU02725KAiJ0ePu5HXUyg6wL72Ko0Narbj5KLsWrzkxIWjPr3LGFIP+ZIX1XG+TfsHlZuxS6wj1mHHCmzQaGHyjcuwnF5uN49NN7BaGW23Y7mAktttpRVrD9y/E9LEUc4zPIqVZur2Hq4aGu0te0mhU9unoAmFR7PdlygMoCEgmz5r19AsQkXD8E/s6iUC3w2BM/D1Hnd3YRoy+TP3MZclxh4l8yZZdclEw47jeBhLDWwv4btz5vksabu4T7IIbyRYKdDEWp3pX+jK8Md9iTMoBSI8GS+5DxA1qKmmEWnlxegQif0qstv28GLXuW2BbqpDROJuE+pZlPfNl5/8wOwFWLyehwPigY8eTXkkzj47dr9THAQ8yaxU367sR5M/FwZb8Q/XPNJDVmQ+ogStIsZB/bvyiZuyuf9DvqtGHN0BqQu6x8BOF7512FbO26CohVau0okqhmX/crag4RMM4B96itgM57z7J2QBy37xaxpjkJ7szyYHLNArXtqKf8d59JoW8z706t4LiEibiMFRRwaUIiMGd9Z/NDIZpyf7bmBJGhLEllBSH06YM6vz9jEdURhB7NGlmSDzC0kB/k+29/FyrXyYS+XkDG4CkGYT7kKrQZAPXI1cEYyvg8h1Na+pyrhUetaeUb+s8nky4Dgk=----ATTACHMENT:----MzUwNTg5MzY2MTkxNzc3NCA5NjQwMjU5MzEyMTA2NzM4IDQ0NzkzNDUyMzY1OTA3Nzk=