Conditions | 6 |
Paths | 6 |
Total Lines | 30 |
Code Lines | 16 |
Lines | 0 |
Ratio | 0 % |
Tests | 0 |
CRAP Score | 42 |
Changes | 0 |
1 | <?php declare(strict_types=1); |
||
19 | public function readTrumpetFile(string $path): Presentation |
||
20 | { |
||
21 | if (!is_readable($path)) { |
||
22 | throw new InvalidArgumentException("Trumpet file '$path' must exist and be readable."); |
||
23 | } |
||
24 | |||
25 | $yaml = file_get_contents($path); |
||
26 | |||
27 | try { |
||
28 | $data = Yaml::parse($yaml, true, true); |
||
29 | } catch (\Throwable $t) { |
||
|
|||
30 | throw new ConfigException($t->getMessage(), 0, $t); |
||
31 | } |
||
32 | |||
33 | if (!is_array($data)) { |
||
34 | throw new ConfigException("Trumpet file '$path' is invalid. It probably is empty."); |
||
35 | } |
||
36 | |||
37 | $presentation = new Presentation(); |
||
38 | |||
39 | foreach ($data as $key => $value) { |
||
40 | if (!array_key_exists($key, $this->params)) { |
||
41 | throw new ConfigException("Trumpet file contains a key '$key' which is not supported."); |
||
42 | } |
||
43 | |||
44 | $this->params[$key]->parse($value, $presentation); |
||
45 | } |
||
46 | |||
47 | return $presentation; |
||
48 | } |
||
49 | } |
||
50 |
Scrutinizer analyzes your
composer.json
/composer.lock
file if available to determine the classes, and functions that are defined by your dependencies.It seems like the listed class was neither found in your dependencies, nor was it found in the analyzed files in your repository. If you are using some other form of dependency management, you might want to disable this analysis.