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