| Conditions | 2 |
| Paths | 2 |
| Total Lines | 34 |
| Code Lines | 23 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 0 |
| CRAP Score | 6 |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 30 | public function run(): CommandResponse |
||
| 31 | { |
||
| 32 | $projectDirectory = $this->aliases->get('@root'); |
||
| 33 | $debugDirectory = $this->aliases->get('@runtime/debug'); |
||
| 34 | |||
| 35 | $outputFilePath = $debugDirectory . DIRECTORY_SEPARATOR . 'psalm-report.json'; |
||
| 36 | |||
| 37 | $params = [ |
||
| 38 | 'vendor/bin/psalm', |
||
| 39 | '--report=' . $outputFilePath, |
||
| 40 | ]; |
||
| 41 | |||
| 42 | $process = new Process($params); |
||
| 43 | |||
| 44 | $process |
||
| 45 | ->setWorkingDirectory($projectDirectory) |
||
| 46 | ->setTimeout(null) |
||
| 47 | ->run(); |
||
| 48 | |||
| 49 | if (!$process->isSuccessful()) { |
||
| 50 | return new CommandResponse( |
||
| 51 | status: CommandResponse::STATUS_ERROR, |
||
| 52 | result: null, |
||
| 53 | errors: [$process->getErrorOutput()], |
||
| 54 | ); |
||
| 55 | } |
||
| 56 | |||
| 57 | return new CommandResponse( |
||
| 58 | status: CommandResponse::STATUS_OK, |
||
| 59 | result: json_decode( |
||
| 60 | file_get_contents($outputFilePath), |
||
| 61 | true, |
||
| 62 | 512, |
||
| 63 | JSON_THROW_ON_ERROR |
||
| 64 | ) |
||
| 68 |