aboutsummaryrefslogtreecommitdiffhomepage
path: root/vendor/symfony/intl/Symfony/Component/Intl/Util/Version.php
diff options
context:
space:
mode:
authorNicolas LÅ“uillet <nicolas.loeuillet@gmail.com>2013-08-04 17:50:34 +0200
committerNicolas LÅ“uillet <nicolas.loeuillet@gmail.com>2013-08-04 17:50:34 +0200
commit46b77928f746a4231d064774b5b67fd892c7ce86 (patch)
treee3ea690b3f0def1744ddae758923cf92171ef985 /vendor/symfony/intl/Symfony/Component/Intl/Util/Version.php
parent68abd9c71b1d2f7bb2e9d21819584d1d15005b25 (diff)
downloadwallabag-46b77928f746a4231d064774b5b67fd892c7ce86.tar.gz
wallabag-46b77928f746a4231d064774b5b67fd892c7ce86.tar.zst
wallabag-46b77928f746a4231d064774b5b67fd892c7ce86.zip
rm vendor
Diffstat (limited to 'vendor/symfony/intl/Symfony/Component/Intl/Util/Version.php')
-rw-r--r--vendor/symfony/intl/Symfony/Component/Intl/Util/Version.php96
1 files changed, 0 insertions, 96 deletions
diff --git a/vendor/symfony/intl/Symfony/Component/Intl/Util/Version.php b/vendor/symfony/intl/Symfony/Component/Intl/Util/Version.php
deleted file mode 100644
index 5f6a4337..00000000
--- a/vendor/symfony/intl/Symfony/Component/Intl/Util/Version.php
+++ /dev/null
@@ -1,96 +0,0 @@
1<?php
2
3/*
4 * This file is part of the Symfony package.
5 *
6 * (c) Fabien Potencier <fabien@symfony.com>
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11
12namespace Symfony\Component\Intl\Util;
13
14/**
15 * Facilitates the comparison of version strings.
16 *
17 * @author Bernhard Schussek <bschussek@gmail.com>
18 */
19class Version
20{
21 /**
22 * Compares two versions with an operator.
23 *
24 * This method is identical to {@link version_compare()}, except that you
25 * can pass the number of regarded version components in the last argument
26 * $precision.
27 *
28 * Examples:
29 *
30 * Version::compare('1.2.3', '1.2.4', '==')
31 * // => false
32 *
33 * Version::compare('1.2.3', '1.2.4', '==', 2)
34 * // => true
35 *
36 * @param string $version1 A version string.
37 * @param string $version2 A version string to compare.
38 * @param string $operator The comparison operator.
39 * @param integer|null $precision The number of components to compare. Pass
40 * NULL to compare the versions unchanged.
41 *
42 * @return Boolean Whether the comparison succeeded.
43 *
44 * @see normalize()
45 */
46 public static function compare($version1, $version2, $operator, $precision = null)
47 {
48 $version1 = self::normalize($version1, $precision);
49 $version2 = self::normalize($version2, $precision);
50
51 return version_compare($version1, $version2, $operator);
52 }
53
54 /**
55 * Normalizes a version string to the number of components given in the
56 * parameter $precision.
57 *
58 * Examples:
59 *
60 * Version::normalize('1.2.3', 1);
61 * // => '1'
62 *
63 * Version::normalize('1.2.3', 2);
64 * // => '1.2'
65 *
66 * @param string $version A version string.
67 * @param integer|null $precision The number of components to include. Pass
68 * NULL to return the version unchanged.
69 *
70 * @return string|null The normalized version or NULL if it couldn't be
71 * normalized.
72 */
73 public static function normalize($version, $precision)
74 {
75 if (null === $precision) {
76 return $version;
77 }
78
79 $pattern = '[^\.]+';
80
81 for ($i = 2; $i <= $precision; ++$i) {
82 $pattern = sprintf('[^\.]+(\.%s)?', $pattern);
83 }
84
85 if (!preg_match('/^' . $pattern . '/', $version, $matches)) {
86 return null;
87 }
88
89 return $matches[0];
90 }
91
92 /**
93 * Must not be instantiated.
94 */
95 private function __construct() {}
96}