1 | <?php |
||
8 | class Reader |
||
9 | { |
||
10 | /** |
||
11 | * Current file pointer. |
||
12 | * |
||
13 | * @var resource |
||
14 | */ |
||
15 | protected $file; |
||
16 | |||
17 | /** |
||
18 | * @var string |
||
19 | */ |
||
20 | protected $filename; |
||
21 | |||
22 | /** |
||
23 | * Whether the current file is little endian. |
||
24 | * |
||
25 | * @var bool |
||
26 | */ |
||
27 | protected $littleEndian; |
||
28 | |||
29 | /** |
||
30 | * @var int |
||
31 | */ |
||
32 | protected $stringsCount; |
||
33 | |||
34 | /** |
||
35 | * @var array |
||
36 | */ |
||
37 | protected $msgIdTable; |
||
38 | |||
39 | /** |
||
40 | * @var array |
||
41 | */ |
||
42 | protected $msgStrTable; |
||
43 | |||
44 | /** |
||
45 | * |
||
46 | * @param string $filename |
||
47 | * @return array |
||
48 | * @throws \Exception |
||
49 | */ |
||
50 | public function load($filename) |
||
65 | |||
66 | /** |
||
67 | * |
||
68 | */ |
||
69 | protected function readStringTables() |
||
83 | |||
84 | /** |
||
85 | * @return array |
||
86 | */ |
||
87 | protected function readTranslations() |
||
100 | |||
101 | /** |
||
102 | * @param array $data |
||
103 | * @param array $msgId |
||
104 | * @param array $msgStr |
||
105 | */ |
||
106 | protected function processRecord(&$data, $msgId, $msgStr) |
||
120 | |||
121 | /** |
||
122 | * Reads specified message id record |
||
123 | * |
||
124 | * @param int $index |
||
125 | * |
||
126 | * @return array |
||
127 | */ |
||
128 | protected function readMsgId($index) |
||
137 | |||
138 | /** |
||
139 | * Reads specified translation record |
||
140 | * |
||
141 | * @param int $index |
||
142 | * |
||
143 | * @return array |
||
144 | */ |
||
145 | protected function readTranslation($index) |
||
154 | |||
155 | /** |
||
156 | * @param int $index |
||
157 | * @param array $table |
||
158 | * |
||
159 | * @return array|bool |
||
160 | */ |
||
161 | protected function readStringFromTable($index, $table) |
||
174 | |||
175 | /** |
||
176 | * @param $counter |
||
177 | * |
||
178 | * @return int |
||
179 | */ |
||
180 | protected function calcSizeKey($counter) |
||
184 | |||
185 | /** |
||
186 | * Prepare file for reading |
||
187 | * |
||
188 | * @param $filename |
||
189 | * |
||
190 | * @throws \Exception |
||
191 | */ |
||
192 | protected function openFile($filename) |
||
215 | |||
216 | /** |
||
217 | * Determines byte order |
||
218 | * |
||
219 | * @throws \Exception |
||
220 | */ |
||
221 | protected function determineByteOrder() |
||
239 | |||
240 | /** |
||
241 | * Verify major revision (only 0 and 1 supported) |
||
242 | * |
||
243 | * @throws \Exception |
||
244 | */ |
||
245 | protected function verifyMajorRevision() |
||
259 | |||
260 | /** |
||
261 | * Read a single integer from the current file. |
||
262 | * |
||
263 | * @return int |
||
264 | */ |
||
265 | protected function readInteger() |
||
275 | |||
276 | /** |
||
277 | * Read an integer from the current file. |
||
278 | * |
||
279 | * @param int $num |
||
280 | * @return array |
||
281 | */ |
||
282 | protected function readIntegerList($num) |
||
290 | } |
||
291 |