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 | public function __construct($fileName) |
||
57 | |||
58 | /** |
||
59 | * Contagem de linhas |
||
60 | * |
||
61 | * @return int |
||
62 | */ |
||
63 | public function count() |
||
82 | |||
83 | /** |
||
84 | * Inicia a leitura do arquivo do inicio |
||
85 | * |
||
86 | * @return void |
||
87 | */ |
||
88 | public function rewind() |
||
94 | |||
95 | /** |
||
96 | * Retorna o indice atual |
||
97 | * |
||
98 | * @return int |
||
99 | */ |
||
100 | public function key() |
||
104 | |||
105 | /** |
||
106 | * Valida se havera proxima linha |
||
107 | * |
||
108 | * @return bool |
||
109 | */ |
||
110 | public function valid() |
||
114 | |||
115 | /** |
||
116 | * Retorna a linha atual |
||
117 | * |
||
118 | * @return string |
||
119 | */ |
||
120 | public function current() |
||
124 | |||
125 | /** |
||
126 | * Busca a proxima linha |
||
127 | * |
||
128 | * @Make return void |
||
129 | */ |
||
130 | public function next() |
||
135 | |||
136 | /** |
||
137 | * Le alinha no arquivo, formata o encodig caso seja necessario |
||
138 | * |
||
139 | * @return string |
||
140 | */ |
||
141 | protected function getLine() |
||
159 | |||
160 | /** |
||
161 | * Ao destruir fecha o arquivo |
||
162 | * |
||
163 | * @return void |
||
164 | */ |
||
165 | public function __destruct() |
||
171 | } |
||
172 |