| Conditions | 5 |
| Paths | 4 |
| Total Lines | 16 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 8 |
| CRAP Score | 5 |
| Changes | 0 | ||
| 1 | <?php |
||
| 25 | 24 | public function jsonFileToArray(string $filePath) |
|
| 26 | { |
||
| 27 | 24 | if (empty($filePath)) { |
|
| 28 | 1 | throw new BotonomousException(self::EMPTY_FILE_PATH_MESSAGE); |
|
| 29 | } |
||
| 30 | |||
| 31 | 23 | if (!file_exists($filePath) || !is_file($filePath)) { |
|
| 32 | 1 | throw new BotonomousException(self::MISSING_FILE_MESSAGE); |
|
| 33 | } |
||
| 34 | |||
| 35 | 22 | if (pathinfo($filePath, PATHINFO_EXTENSION) !== 'json') { |
|
| 36 | 1 | throw new BotonomousException(self::INVALID_JSON_FILE_MESSAGE); |
|
| 37 | } |
||
| 38 | |||
| 39 | 21 | return (new StringUtility())->jsonToArray(file_get_contents($filePath)); |
|
| 40 | } |
||
| 41 | } |
||
| 42 |