Vous êtes connecté en tant que anonymous Se Deconnecter
Browse code

Application modulaire fonctionnelle !

Emmanuel ROY authored on 12/08/2019 15:10:25
Showing 1 changed files
1 1
deleted file mode 100644
... ...
@@ -1,112 +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
-
12
-namespace Symfony\Component\Translation;
13
-
14
-@trigger_error(sprintf('The "%s" class is deprecated since Symfony 4.2, use IdentityTranslator instead.', Interval::class), E_USER_DEPRECATED);
15
-
16
-use Symfony\Component\Translation\Exception\InvalidArgumentException;
17
-
18
-/**
19
- * Tests if a given number belongs to a given math interval.
20
- *
21
- * An interval can represent a finite set of numbers:
22
- *
23
- *  {1,2,3,4}
24
- *
25
- * An interval can represent numbers between two numbers:
26
- *
27
- *  [1, +Inf]
28
- *  ]-1,2[
29
- *
30
- * The left delimiter can be [ (inclusive) or ] (exclusive).
31
- * The right delimiter can be [ (exclusive) or ] (inclusive).
32
- * Beside numbers, you can use -Inf and +Inf for the infinite.
33
- *
34
- * @author Fabien Potencier <fabien@symfony.com>
35
- *
36
- * @see    http://en.wikipedia.org/wiki/Interval_%28mathematics%29#The_ISO_notation
37
- * @deprecated since Symfony 4.2, use IdentityTranslator instead
38
- */
39
-class Interval
40
-{
41
-    /**
42
-     * Tests if the given number is in the math interval.
43
-     *
44
-     * @param int    $number   A number
45
-     * @param string $interval An interval
46
-     *
47
-     * @return bool
48
-     *
49
-     * @throws InvalidArgumentException
50
-     */
51
-    public static function test($number, $interval)
52
-    {
53
-        $interval = trim($interval);
54
-
55
-        if (!preg_match('/^'.self::getIntervalRegexp().'$/x', $interval, $matches)) {
56
-            throw new InvalidArgumentException(sprintf('"%s" is not a valid interval.', $interval));
57
-        }
58
-
59
-        if ($matches[1]) {
60
-            foreach (explode(',', $matches[2]) as $n) {
61
-                if ($number == $n) {
62
-                    return true;
63
-                }
64
-            }
65
-        } else {
66
-            $leftNumber = self::convertNumber($matches['left']);
67
-            $rightNumber = self::convertNumber($matches['right']);
68
-
69
-            return
70
-                ('[' === $matches['left_delimiter'] ? $number >= $leftNumber : $number > $leftNumber)
71
-                && (']' === $matches['right_delimiter'] ? $number <= $rightNumber : $number < $rightNumber)
72
-            ;
73
-        }
74
-
75
-        return false;
76
-    }
77
-
78
-    /**
79
-     * Returns a Regexp that matches valid intervals.
80
-     *
81
-     * @return string A Regexp (without the delimiters)
82
-     */
83
-    public static function getIntervalRegexp()
84
-    {
85
-        return <<<EOF
86
-        ({\s*
87
-            (\-?\d+(\.\d+)?[\s*,\s*\-?\d+(\.\d+)?]*)
88
-        \s*})
89
-
90
-            |
91
-
92
-        (?P<left_delimiter>[\[\]])
93
-            \s*
94
-            (?P<left>-Inf|\-?\d+(\.\d+)?)
95
-            \s*,\s*
96
-            (?P<right>\+?Inf|\-?\d+(\.\d+)?)
97
-            \s*
98
-        (?P<right_delimiter>[\[\]])
99
-EOF;
100
-    }
101
-
102
-    private static function convertNumber($number)
103
-    {
104
-        if ('-Inf' === $number) {
105
-            return log(0);
106
-        } elseif ('+Inf' === $number || 'Inf' === $number) {
107
-            return -log(0);
108
-        }
109
-
110
-        return (float) $number;
111
-    }
112
-}
Browse code

initial commit

Emmanuel ROY authored on 09/08/2019 08:39:02
Showing 1 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,112 @@
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
+
12
+namespace Symfony\Component\Translation;
13
+
14
+@trigger_error(sprintf('The "%s" class is deprecated since Symfony 4.2, use IdentityTranslator instead.', Interval::class), E_USER_DEPRECATED);
15
+
16
+use Symfony\Component\Translation\Exception\InvalidArgumentException;
17
+
18
+/**
19
+ * Tests if a given number belongs to a given math interval.
20
+ *
21
+ * An interval can represent a finite set of numbers:
22
+ *
23
+ *  {1,2,3,4}
24
+ *
25
+ * An interval can represent numbers between two numbers:
26
+ *
27
+ *  [1, +Inf]
28
+ *  ]-1,2[
29
+ *
30
+ * The left delimiter can be [ (inclusive) or ] (exclusive).
31
+ * The right delimiter can be [ (exclusive) or ] (inclusive).
32
+ * Beside numbers, you can use -Inf and +Inf for the infinite.
33
+ *
34
+ * @author Fabien Potencier <fabien@symfony.com>
35
+ *
36
+ * @see    http://en.wikipedia.org/wiki/Interval_%28mathematics%29#The_ISO_notation
37
+ * @deprecated since Symfony 4.2, use IdentityTranslator instead
38
+ */
39
+class Interval
40
+{
41
+    /**
42
+     * Tests if the given number is in the math interval.
43
+     *
44
+     * @param int    $number   A number
45
+     * @param string $interval An interval
46
+     *
47
+     * @return bool
48
+     *
49
+     * @throws InvalidArgumentException
50
+     */
51
+    public static function test($number, $interval)
52
+    {
53
+        $interval = trim($interval);
54
+
55
+        if (!preg_match('/^'.self::getIntervalRegexp().'$/x', $interval, $matches)) {
56
+            throw new InvalidArgumentException(sprintf('"%s" is not a valid interval.', $interval));
57
+        }
58
+
59
+        if ($matches[1]) {
60
+            foreach (explode(',', $matches[2]) as $n) {
61
+                if ($number == $n) {
62
+                    return true;
63
+                }
64
+            }
65
+        } else {
66
+            $leftNumber = self::convertNumber($matches['left']);
67
+            $rightNumber = self::convertNumber($matches['right']);
68
+
69
+            return
70
+                ('[' === $matches['left_delimiter'] ? $number >= $leftNumber : $number > $leftNumber)
71
+                && (']' === $matches['right_delimiter'] ? $number <= $rightNumber : $number < $rightNumber)
72
+            ;
73
+        }
74
+
75
+        return false;
76
+    }
77
+
78
+    /**
79
+     * Returns a Regexp that matches valid intervals.
80
+     *
81
+     * @return string A Regexp (without the delimiters)
82
+     */
83
+    public static function getIntervalRegexp()
84
+    {
85
+        return <<<EOF
86
+        ({\s*
87
+            (\-?\d+(\.\d+)?[\s*,\s*\-?\d+(\.\d+)?]*)
88
+        \s*})
89
+
90
+            |
91
+
92
+        (?P<left_delimiter>[\[\]])
93
+            \s*
94
+            (?P<left>-Inf|\-?\d+(\.\d+)?)
95
+            \s*,\s*
96
+            (?P<right>\+?Inf|\-?\d+(\.\d+)?)
97
+            \s*
98
+        (?P<right_delimiter>[\[\]])
99
+EOF;
100
+    }
101
+
102
+    private static function convertNumber($number)
103
+    {
104
+        if ('-Inf' === $number) {
105
+            return log(0);
106
+        } elseif ('+Inf' === $number || 'Inf' === $number) {
107
+            return -log(0);
108
+        }
109
+
110
+        return (float) $number;
111
+    }
112
+}