1 | <?php |
||
18 | class LogIterator implements \Iterator |
||
19 | { |
||
20 | /** |
||
21 | * @var LineParserInterface |
||
22 | */ |
||
23 | private $parser; |
||
24 | |||
25 | /** |
||
26 | * @var string |
||
27 | */ |
||
28 | private $logFile; |
||
29 | |||
30 | /** |
||
31 | * @var resource |
||
32 | */ |
||
33 | private $fileHandler; |
||
34 | |||
35 | /** |
||
36 | * @var string |
||
37 | */ |
||
38 | private $currentLine; |
||
39 | |||
40 | /** |
||
41 | * @var bool |
||
42 | */ |
||
43 | private $skipEmptyLines; |
||
44 | |||
45 | /** |
||
46 | * Constructor. |
||
47 | * |
||
48 | * @param string $logFile |
||
49 | * @param LineParserInterface $parser |
||
50 | * @param bool $skipEmptyLines |
||
51 | */ |
||
52 | 5 | public function __construct($logFile, $parser, $skipEmptyLines = true) |
|
58 | |||
59 | /** |
||
60 | * Destructor. |
||
61 | */ |
||
62 | 5 | public function __destruct() |
|
66 | |||
67 | /** |
||
68 | * Returns file handler. |
||
69 | * |
||
70 | * @return resource |
||
71 | * @throws ParserException |
||
72 | */ |
||
73 | 5 | protected function getFileHandler() |
|
87 | |||
88 | /** |
||
89 | * Reads single line from file. |
||
90 | * |
||
91 | * @throws ParserException |
||
92 | */ |
||
93 | 4 | protected function readLine() |
|
112 | |||
113 | /** |
||
114 | * Returns parsed current line. |
||
115 | * |
||
116 | * @return array|null |
||
117 | */ |
||
118 | 4 | public function current() |
|
132 | |||
133 | /** |
||
134 | * {@inheritdoc} |
||
135 | */ |
||
136 | 4 | public function next() |
|
140 | |||
141 | /** |
||
142 | * Returns current line |
||
143 | * |
||
144 | * @return string |
||
145 | */ |
||
146 | 2 | public function key() |
|
150 | |||
151 | /** |
||
152 | * {@inheritdoc} |
||
153 | */ |
||
154 | 4 | public function valid() |
|
158 | |||
159 | /** |
||
160 | * {@inheritdoc} |
||
161 | */ |
||
162 | 5 | public function rewind() |
|
166 | } |
||
167 |
If you suppress an error, we recommend checking for the error condition explicitly: