diff options
Diffstat (limited to 'vendor/symfony/intl/Symfony/Component/Intl/Globals/IntlGlobals.php')
-rw-r--r-- | vendor/symfony/intl/Symfony/Component/Intl/Globals/IntlGlobals.php | 137 |
1 files changed, 0 insertions, 137 deletions
diff --git a/vendor/symfony/intl/Symfony/Component/Intl/Globals/IntlGlobals.php b/vendor/symfony/intl/Symfony/Component/Intl/Globals/IntlGlobals.php deleted file mode 100644 index 6da00011..00000000 --- a/vendor/symfony/intl/Symfony/Component/Intl/Globals/IntlGlobals.php +++ /dev/null | |||
@@ -1,137 +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\Intl\Globals; | ||
13 | |||
14 | /** | ||
15 | * Provides fake static versions of the global functions in the intl extension | ||
16 | * | ||
17 | * @author Bernhard Schussek <bschussek@gmail.com> | ||
18 | */ | ||
19 | abstract class IntlGlobals | ||
20 | { | ||
21 | /** | ||
22 | * Indicates that no error occurred | ||
23 | * | ||
24 | * @var integer | ||
25 | */ | ||
26 | const U_ZERO_ERROR = 0; | ||
27 | |||
28 | /** | ||
29 | * Indicates that an invalid argument was passed | ||
30 | * | ||
31 | * @var integer | ||
32 | */ | ||
33 | const U_ILLEGAL_ARGUMENT_ERROR = 1; | ||
34 | |||
35 | /** | ||
36 | * Indicates that the parse() operation failed | ||
37 | * | ||
38 | * @var integer | ||
39 | */ | ||
40 | const U_PARSE_ERROR = 9; | ||
41 | |||
42 | /** | ||
43 | * All known error codes | ||
44 | * | ||
45 | * @var array | ||
46 | */ | ||
47 | private static $errorCodes = array( | ||
48 | self::U_ZERO_ERROR => 'U_ZERO_ERROR', | ||
49 | self::U_ILLEGAL_ARGUMENT_ERROR => 'U_ILLEGAL_ARGUMENT_ERROR', | ||
50 | self::U_PARSE_ERROR => 'U_PARSE_ERROR', | ||
51 | ); | ||
52 | |||
53 | /** | ||
54 | * The error code of the last operation | ||
55 | * | ||
56 | * @var integer | ||
57 | */ | ||
58 | private static $errorCode = self::U_ZERO_ERROR; | ||
59 | |||
60 | /** | ||
61 | * The error code of the last operation | ||
62 | * | ||
63 | * @var integer | ||
64 | */ | ||
65 | private static $errorMessage = 'U_ZERO_ERROR'; | ||
66 | |||
67 | /** | ||
68 | * Returns whether the error code indicates a failure | ||
69 | * | ||
70 | * @param integer $errorCode The error code returned by IntlGlobals::getErrorCode() | ||
71 | * | ||
72 | * @return Boolean | ||
73 | */ | ||
74 | public static function isFailure($errorCode) | ||
75 | { | ||
76 | return isset(self::$errorCodes[$errorCode]) | ||
77 | && $errorCode > self::U_ZERO_ERROR; | ||
78 | } | ||
79 | |||
80 | /** | ||
81 | * Returns the error code of the last operation | ||
82 | * | ||
83 | * Returns IntlGlobals::U_ZERO_ERROR if no error occurred. | ||
84 | * | ||
85 | * @return integer | ||
86 | */ | ||
87 | public static function getErrorCode() | ||
88 | { | ||
89 | return self::$errorCode; | ||
90 | } | ||
91 | |||
92 | /** | ||
93 | * Returns the error message of the last operation | ||
94 | * | ||
95 | * Returns "U_ZERO_ERROR" if no error occurred. | ||
96 | * | ||
97 | * @return string | ||
98 | */ | ||
99 | public static function getErrorMessage() | ||
100 | { | ||
101 | return self::$errorMessage; | ||
102 | } | ||
103 | |||
104 | /** | ||
105 | * Returns the symbolic name for a given error code | ||
106 | * | ||
107 | * @param integer $code The error code returned by IntlGlobals::getErrorCode() | ||
108 | * | ||
109 | * @return string | ||
110 | */ | ||
111 | public static function getErrorName($code) | ||
112 | { | ||
113 | if (isset(self::$errorCodes[$code])) { | ||
114 | return self::$errorCodes[$code]; | ||
115 | } | ||
116 | |||
117 | return '[BOGUS UErrorCode]'; | ||
118 | } | ||
119 | |||
120 | /** | ||
121 | * Sets the current error | ||
122 | * | ||
123 | * @param integer $code One of the error constants in this class | ||
124 | * @param string $message The ICU class error message | ||
125 | * | ||
126 | * @throws \InvalidArgumentException If the code is not one of the error constants in this class | ||
127 | */ | ||
128 | public static function setError($code, $message = '') | ||
129 | { | ||
130 | if (!isset(self::$errorCodes[$code])) { | ||
131 | throw new \InvalidArgumentException(sprintf('No such error code: "%s"', $code)); | ||
132 | } | ||
133 | |||
134 | self::$errorMessage = $message ? sprintf('%s: %s', $message, self::$errorCodes[$code]) : self::$errorCodes[$code]; | ||
135 | self::$errorCode = $code; | ||
136 | } | ||
137 | } | ||