1 | <?php |
||
8 | abstract class AbstractIteratorFile implements \Iterator, \Countable |
||
9 | { |
||
10 | /** |
||
11 | * @var string |
||
12 | */ |
||
13 | protected $fileName; |
||
14 | |||
15 | /** |
||
16 | * @var resource |
||
17 | */ |
||
18 | protected $fileHandle; |
||
19 | |||
20 | /** |
||
21 | * @var mixed |
||
22 | */ |
||
23 | protected $current; |
||
24 | |||
25 | /** |
||
26 | * @var int |
||
27 | */ |
||
28 | protected $key; |
||
29 | |||
30 | /** |
||
31 | * @var int |
||
32 | */ |
||
33 | protected $count; |
||
34 | |||
35 | /** |
||
36 | * Make Row Current |
||
37 | * |
||
38 | * @return mixed |
||
39 | */ |
||
40 | abstract protected function makeCurrent(); |
||
41 | |||
42 | /** |
||
43 | * Abre o arquivo para leitura |
||
44 | * |
||
45 | * @param string $fileName Path |
||
46 | * |
||
47 | * @throws \RuntimeException |
||
48 | */ |
||
49 | 8 | public function __construct($fileName) |
|
57 | |||
58 | /** |
||
59 | * Contagem de linhas |
||
60 | * |
||
61 | * @return int |
||
62 | */ |
||
63 | 1 | public function count() |
|
75 | |||
76 | /** |
||
77 | * Inicia a leitura do arquivo do inicio |
||
78 | * |
||
79 | * @return void |
||
80 | */ |
||
81 | 2 | public function rewind() |
|
87 | |||
88 | /** |
||
89 | * Retorna o indice atual |
||
90 | * |
||
91 | * @return int |
||
92 | */ |
||
93 | 1 | public function key() |
|
97 | |||
98 | /** |
||
99 | * Valida se havera proxima linha |
||
100 | * |
||
101 | * @return bool |
||
102 | */ |
||
103 | 2 | public function valid() |
|
107 | |||
108 | /** |
||
109 | * Retorna a linha atual |
||
110 | * |
||
111 | * @return string |
||
112 | */ |
||
113 | 2 | public function current() |
|
117 | |||
118 | /** |
||
119 | * Busca a proxima linha |
||
120 | * |
||
121 | * @Make return void |
||
122 | */ |
||
123 | 2 | public function next() |
|
128 | |||
129 | /** |
||
130 | * Le alinha no arquivo, formata o encodig caso seja necessario |
||
131 | * |
||
132 | * @return string |
||
133 | */ |
||
134 | 1 | protected function getLine() |
|
152 | |||
153 | /** |
||
154 | * Ao destruir fecha o arquivo |
||
155 | * |
||
156 | * @return void |
||
157 | */ |
||
158 | 7 | public function __destruct() |
|
164 | } |
||
165 |