| Conditions | 4 |
| Paths | 4 |
| Total Lines | 23 |
| Code Lines | 12 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 2 | ||
| Bugs | 0 | Features | 1 |
| 1 | <?php |
||
| 20 | public function readToArray($source) |
||
| 21 | { |
||
| 22 | if (!file_exists($source)) { |
||
| 23 | throw new \Vaimo\ComposerChangelogs\Exceptions\ReaderException( |
||
| 24 | sprintf('File not found: %s', $source) |
||
| 25 | ); |
||
| 26 | } |
||
| 27 | |||
| 28 | $sourceData = file_get_contents($source); |
||
| 29 | |||
| 30 | try { |
||
| 31 | $fileContents = $this->jsonDecoder->decode($sourceData); |
||
| 32 | } catch (\Vaimo\ComposerChangelogs\Exceptions\DecoderException $exception) { |
||
| 33 | $message = sprintf('Failed to retrieve contents of %s', $source); |
||
| 34 | |||
| 35 | throw new \Vaimo\ComposerChangelogs\Exceptions\ReaderException($message, 0, $exception); |
||
| 36 | } |
||
| 37 | |||
| 38 | if (!is_array($fileContents)) { |
||
| 39 | return array(); |
||
| 40 | } |
||
| 41 | |||
| 42 | return $fileContents; |
||
| 43 | } |
||
| 45 |