1 | <?php namespace FreedomCore\TrinityCore\Support; |
||
12 | class DB2Reader |
||
13 | { |
||
14 | |||
15 | /** |
||
16 | * File manager instance |
||
17 | * @var FileManager|null |
||
18 | */ |
||
19 | protected $fileManager = null; |
||
20 | |||
21 | /** |
||
22 | * File system instance |
||
23 | * @var Filesystem|null |
||
24 | */ |
||
25 | protected $fileSystem = null; |
||
26 | |||
27 | /** |
||
28 | * Processor Instance |
||
29 | * @var WDB5|WDB2|BaseFormat|null |
||
30 | */ |
||
31 | protected $processor = null; |
||
32 | |||
33 | /** |
||
34 | * Language which will be used to open DBC files |
||
35 | * @var string |
||
36 | */ |
||
37 | protected $selectedLanguage = 'enUS'; |
||
38 | |||
39 | /** |
||
40 | * Build used for extraction |
||
41 | * @var null|integer |
||
42 | */ |
||
43 | protected $build = null; |
||
44 | |||
45 | /** |
||
46 | * Displays whether the file is already opened or not |
||
47 | * @var bool |
||
48 | */ |
||
49 | protected $fileOpened = false; |
||
50 | |||
51 | /** |
||
52 | * DB2Reader constructor. |
||
53 | * @param bool $initializeImmediately |
||
54 | */ |
||
55 | public function __construct(bool $initializeImmediately = false) |
||
67 | |||
68 | /** |
||
69 | * Get file manager instance |
||
70 | * @return FileManager |
||
71 | */ |
||
72 | public function getFileManager() : FileManager |
||
76 | |||
77 | /** |
||
78 | * Set new file manager instance |
||
79 | * @param FileManager $fileManager |
||
80 | */ |
||
81 | public function setFileManager(FileManager $fileManager) |
||
85 | |||
86 | /** |
||
87 | * Get language currently used for processing |
||
88 | * @return string |
||
89 | */ |
||
90 | public function getLanguage() : string |
||
94 | |||
95 | /** |
||
96 | * Set language used for DBC processing |
||
97 | * @param string $language |
||
98 | * @param bool $throwIfAny |
||
99 | */ |
||
100 | public function setLanguage(string $language, bool $throwIfAny = true) |
||
111 | |||
112 | /** |
||
113 | * Get latest build |
||
114 | */ |
||
115 | public function getLatestBuild() |
||
124 | |||
125 | /** |
||
126 | * Get build used for processing |
||
127 | * @return int |
||
128 | */ |
||
129 | public function getBuild() : int |
||
133 | |||
134 | /** |
||
135 | * Set build which will be used for processing |
||
136 | * @param int $build |
||
137 | */ |
||
138 | public function setBuild(int $build) |
||
142 | |||
143 | /** |
||
144 | * Open requested file |
||
145 | * @param string $fileName |
||
146 | * @throws \Exception |
||
147 | */ |
||
148 | public function openFile(string $fileName) |
||
163 | |||
164 | /** |
||
165 | * Check if file is already opened |
||
166 | * @return bool |
||
167 | */ |
||
168 | public function isFileOpened() : bool |
||
172 | |||
173 | /** |
||
174 | * Get record by ID |
||
175 | * @param int $id |
||
176 | * @return array|null |
||
177 | * @throws \Exception |
||
178 | */ |
||
179 | public function getRecord(int $id) |
||
183 | |||
184 | /** |
||
185 | * Generate Records |
||
186 | * @return \Generator |
||
187 | * @throws \Exception |
||
188 | */ |
||
189 | public function generateRecords() : \Generator |
||
193 | |||
194 | /** |
||
195 | * Get indexes |
||
196 | * @return array |
||
197 | */ |
||
198 | public function getIndexes() : array |
||
202 | |||
203 | /** |
||
204 | * Get Processor Instance |
||
205 | * @return BaseFormat|WDB2|WDB5|null |
||
206 | */ |
||
207 | public function getProcessor() |
||
211 | |||
212 | /** |
||
213 | * Flatten record |
||
214 | * @param array $record |
||
215 | * @return array |
||
216 | */ |
||
217 | public static function flattenRecord(array $record) : array |
||
232 | } |
||
233 |