Conditions | 3 |
Paths | 2 |
Total Lines | 27 |
Code Lines | 16 |
Lines | 0 |
Ratio | 0 % |
Tests | 0 |
CRAP Score | 12 |
Changes | 2 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
20 | public function read(Aliases $aliases): ResponseInterface |
||
21 | { |
||
22 | $command = new BashCommand($aliases, [ |
||
23 | 'composer', |
||
24 | 'yii-config-merge-plan', |
||
25 | ]); |
||
26 | $output = $command->run()->getResult(); |
||
27 | $mergePlanPath = substr($output, 0, strpos($output, 'Xdebug: [Step Debug]') ?: -1); |
||
28 | |||
29 | if (!file_exists($mergePlanPath)) { |
||
30 | throw new Exception( |
||
31 | sprintf( |
||
32 | 'Could not find composer.json by the path "%s".', |
||
33 | $mergePlanPath, |
||
34 | ) |
||
35 | ); |
||
36 | } |
||
37 | |||
38 | $content = require $mergePlanPath; |
||
39 | $rootAlias = $aliases->get('@root'); |
||
40 | |||
41 | $result = [ |
||
42 | 'path' => substr($mergePlanPath, strlen($rootAlias) + 1), |
||
43 | 'data' => $content, |
||
44 | ]; |
||
45 | |||
46 | return $this->responseFactory->createResponse($result); |
||
47 | } |
||
49 |