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