1 | <?php |
||
11 | class Text |
||
12 | { |
||
13 | const TEXT_CH = '/^[A-Za-z0-9 .,:\'\/()?+\-!"#%&*;<>÷=@_$£[\]{}\` ́~àáâäçèéêëìíîïñòóôöùúûüýßÀÁÂÄÇÈÉÊËÌÍÎÏÒÓÔÖÙÚÛÜÑ]*$/u'; |
||
14 | const TEXT_SWIFT = '/^[A-Za-z0-9 .,:\'\/()?+\-]*$/'; |
||
15 | |||
16 | 3 | public static function assertOptional($input, $maxLength) |
|
24 | |||
25 | 7 | public static function assert($input, $maxLength) |
|
29 | |||
30 | 6 | public static function assertIdentifier($input) |
|
39 | |||
40 | 3 | public static function assertCountryCode($input) |
|
48 | |||
49 | 10 | private static function assertPattern($input, $maxLength, $pattern) |
|
50 | { |
||
51 | 10 | $length = function_exists('mb_strlen') ? mb_strlen($input, 'UTF-8') : strlen($input); |
|
52 | 10 | if (!is_string($input) || $length === 0 || $length > $maxLength) { |
|
53 | 1 | throw new InvalidArgumentException(sprintf('The string can not be empty or longer than %d characters.', $maxLength)); |
|
54 | } |
||
55 | 9 | if (!preg_match($pattern, $input)) { |
|
56 | 1 | throw new InvalidArgumentException('The string contains invalid characters.'); |
|
57 | } |
||
58 | |||
59 | 8 | return $input; |
|
60 | } |
||
61 | |||
62 | 3 | public static function xml(DOMDocument $doc, $tag, $content) |
|
69 | } |
||
70 |