Conditions | 3 |
Paths | 3 |
Total Lines | 21 |
Code Lines | 11 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 1 |
1 | <?php |
||
21 | public function loadFromFile($path) |
||
22 | { |
||
23 | // the file should exists |
||
24 | $fileSystem = new Filesystem(); |
||
25 | |||
26 | if (!$fileSystem->exists($path)) { |
||
27 | throw new FileNotFoundException(); |
||
28 | } |
||
29 | // the file should be a yml file |
||
30 | $configurationFile = new SplFileInfo($path); |
||
31 | |||
32 | if ($configurationFile->getExtension() !== 'yml') { |
||
33 | throw new Exception('Only yml are allowed for assets configuration loading'); |
||
34 | } |
||
35 | // parse configuration using Symfony processor |
||
36 | $configuration = Yaml::parse(file_get_contents($path)); |
||
37 | $configurationDI = new Configuration(); |
||
38 | $processor = new Processor(); |
||
39 | |||
40 | return $processor->processConfiguration($configurationDI, $configuration); |
||
41 | } |
||
42 | } |
||
43 |