Passed
Pull Request — master (#51)
by Dmitriy
02:37
created

PsalmCommand   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
eloc 15
c 1
b 0
f 0
dl 0
loc 28
ccs 0
cts 13
cp 0
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A run() 0 22 1
A __construct() 0 2 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Yiisoft\Yii\Debug\Api\Inspector\Command;
6
7
use Symfony\Component\Process\Process;
8
use Yiisoft\Aliases\Aliases;
9
10
class PsalmCommand
11
{
12
    public function __construct(private Aliases $aliases)
13
    {
14
    }
15
16
    public function run()
17
    {
18
        $projectDirectory = $this->aliases->get('@root');
19
        $debugDirectory = $this->aliases->get('@runtime/debug');
20
21
        $outputFilePath = $debugDirectory . DIRECTORY_SEPARATOR . 'psalm-report.json';
22
23
        $params = [
24
            'vendor/bin/psalm',
25
            '--report=' . $outputFilePath,
26
        ];
27
28
        $process = new Process($params);
29
30
        $process
31
            ->setWorkingDirectory($projectDirectory)
32
            ->setTimeout(null)
33
            ->run();
34
35
        return json_decode(
36
            file_get_contents($outputFilePath),
37
            true
38
        );
39
    }
40
}
41