1 | <?php |
||
15 | class RegexIterator implements \IteratorAggregate |
||
16 | { |
||
17 | public const PREG_PARSING_ERROR = 'The error occurs while compiling PCRE'; |
||
18 | public const PREG_INTERNAL_ERROR = 'There was an internal PCRE error'; |
||
19 | public const PREG_BACKTRACK_LIMIT_ERROR = 'Backtrack limit was exhausted'; |
||
20 | public const PREG_RECURSION_LIMIT_ERROR = 'Recursion limit was exhausted'; |
||
21 | public const PREG_BAD_UTF8_ERROR = 'The offset didn\'t correspond to the begin of a valid UTF-8 code point'; |
||
22 | public const PREG_BAD_UTF8_OFFSET_ERROR = 'Malformed UTF-8 data'; |
||
23 | |||
24 | /** |
||
25 | * @var string |
||
26 | */ |
||
27 | private $pattern; |
||
28 | |||
29 | /** |
||
30 | * @var string |
||
31 | */ |
||
32 | private $subject; |
||
33 | |||
34 | /** |
||
35 | * RegexIterator constructor. |
||
36 | * @param string $pattern |
||
37 | * @param string $subject |
||
38 | */ |
||
39 | 17 | public function __construct(string $pattern, string $subject) |
|
44 | |||
45 | /** |
||
46 | * @return \Traversable|array[] |
||
47 | * @throws \InvalidArgumentException |
||
48 | * @throws \RuntimeException |
||
49 | */ |
||
50 | 17 | public function getIterator(): \Traversable |
|
62 | |||
63 | /** |
||
64 | * @param $status |
||
65 | * @return void |
||
66 | * @throws \InvalidArgumentException |
||
67 | * @throws \RuntimeException |
||
68 | */ |
||
69 | 17 | private function validate($status): void |
|
83 | |||
84 | /** |
||
85 | * @param int $code |
||
86 | * @return string |
||
87 | */ |
||
88 | private function getErrorMessage(int $code): string |
||
108 | 17 | ||
109 | /** |
||
110 | 17 | * Destroy current body |
|
111 | 17 | */ |
|
112 | public function __destruct() |
||
116 | } |
||
117 |
As per the PSR-2 coding standard, case statements should not be wrapped in curly braces. There is no need for braces, since each case is terminated by the next
break
.There is also the option to use a semicolon instead of a colon, this is discouraged because many programmers do not even know it works and the colon is universal between programming languages.
To learn more about the PSR-2 coding standard, please refer to the PHP-Fig.