Passed
Push — master ( 7b8c40...1ad09b )
by Dmitriy
02:53 queued 12s
created

PsalmCommand::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 2
Code Lines 0

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 0
c 1
b 0
f 0
dl 0
loc 2
ccs 0
cts 1
cp 0
rs 10
cc 1
nc 1
nop 1
crap 2
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