123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139 |
- <?php
- namespace Symfony\Component\Intl\Globals;
- abstract class IntlGlobals
- {
-
- const U_ZERO_ERROR = 0;
-
- const U_ILLEGAL_ARGUMENT_ERROR = 1;
-
- const U_PARSE_ERROR = 9;
-
- private static $errorCodes = array(
- self::U_ZERO_ERROR => 'U_ZERO_ERROR',
- self::U_ILLEGAL_ARGUMENT_ERROR => 'U_ILLEGAL_ARGUMENT_ERROR',
- self::U_PARSE_ERROR => 'U_PARSE_ERROR',
- );
-
- private static $errorCode = self::U_ZERO_ERROR;
-
- private static $errorMessage = 'U_ZERO_ERROR';
-
- public static function isFailure($errorCode)
- {
- return isset(self::$errorCodes[$errorCode])
- && $errorCode > self::U_ZERO_ERROR;
- }
-
- public static function getErrorCode()
- {
- return self::$errorCode;
- }
-
- public static function getErrorMessage()
- {
- return self::$errorMessage;
- }
-
- public static function getErrorName($code)
- {
- if (isset(self::$errorCodes[$code])) {
- return self::$errorCodes[$code];
- }
- return '[BOGUS UErrorCode]';
- }
-
- public static function setError($code, $message = '')
- {
- if (!isset(self::$errorCodes[$code])) {
- throw new \InvalidArgumentException(sprintf('No such error code: "%s"', $code));
- }
- self::$errorMessage = $message ? sprintf('%s: %s', $message, self::$errorCodes[$code]) : self::$errorCodes[$code];
- self::$errorCode = $code;
- }
- }
|