Conditions | 5 |
Paths | 4 |
Total Lines | 16 |
Code Lines | 8 |
Lines | 0 |
Ratio | 0 % |
Tests | 0 |
CRAP Score | 30 |
Changes | 0 |
1 | <?php |
||
15 | protected function validateSyntax() |
||
16 | { |
||
17 | $data = json_decode(file_get_contents($this->filePath), true); |
||
18 | |||
19 | if (json_last_error()) { |
||
20 | throw ImportFileException::invalidSyntax($this->file->getFilename()); |
||
21 | } |
||
22 | |||
23 | $fields = array_keys($data[0]); |
||
24 | |||
25 | foreach ($data as $row) { |
||
26 | if (count($fields) != count($row) || count(array_intersect($fields, array_keys($row))) != count($fields)) { |
||
27 | throw ImportFileException::invalidSyntax($this->file->getFilename(), 'Fields not consistent'); |
||
28 | } |
||
29 | } |
||
30 | } |
||
31 | |||
44 |