Conditions | 4 |
Paths | 3 |
Total Lines | 15 |
Code Lines | 9 |
Lines | 0 |
Ratio | 0 % |
Changes | 2 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
44 | public function load($filename) { |
||
45 | |||
46 | if(!\file_exists($filename) ||!\is_readable($filename)) { |
||
47 | throw new \RuntimeException('configuration file is not accessible'); |
||
48 | } |
||
49 | $content = file_get_contents($filename); |
||
50 | $parser = new Yaml(); |
||
51 | $array = $parser->parse($content); |
||
52 | if (null === $array) { |
||
53 | throw new \RuntimeException('configuration file is empty'); |
||
54 | } |
||
55 | |||
56 | return $this->hydrator->hydrates(new Configuration, $array); |
||
|
|||
57 | |||
58 | } |
||
59 | } |
If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:
If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.