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 | 6 | public function __construct(string $pattern, string $subject) |
|
44 | |||
45 | /** |
||
46 | * @return \Traversable|array[] |
||
47 | * @throws \InvalidArgumentException |
||
48 | * @throws \RuntimeException |
||
49 | */ |
||
50 | 6 | public function getIterator(): \Traversable |
|
62 | |||
63 | /** |
||
64 | * @param $status |
||
65 | * @return void |
||
66 | * @throws \InvalidArgumentException |
||
67 | * @throws \RuntimeException |
||
68 | */ |
||
69 | 6 | private function validate($status): void |
|
83 | |||
84 | /** |
||
85 | * @param int $code |
||
86 | * @return string |
||
87 | */ |
||
88 | private function getErrorMessage(int $code): string |
||
108 | |||
109 | /** |
||
110 | * Destroy current body |
||
111 | */ |
||
112 | 6 | public function __destruct() |
|
116 | } |
||
117 |