GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

Psalm   A
last analyzed

Complexity

Total Complexity 8

Size/Duplication

Total Lines 61
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 8
eloc 38
c 1
b 0
f 1
dl 0
loc 61
ccs 33
cts 33
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
B __invoke() 0 50 7
1
<?php
2
declare(strict_types = 1);
3
4
namespace Innmind\LabStation\Trigger;
5
6
use Innmind\LabStation\{
7
    Trigger,
8
    Activity,
9
    Activity\Type,
10
};
11
use Innmind\CLI\Environment;
12
use Innmind\Server\Control\Server\{
13
    Processes,
14
    Command,
15
    Process\Output,
16
};
17
use Innmind\OperatingSystem\Filesystem;
18
use Innmind\Immutable\Str;
19
20
final class Psalm implements Trigger
21
{
22
    private $processes;
23
    private $filesystem;
24
25 16
    public function __construct(Processes $processes, Filesystem $filesystem)
26
    {
27 16
        $this->processes = $processes;
28 16
        $this->filesystem = $filesystem;
29 16
    }
30
31 12
    public function __invoke(Activity $activity, Environment $env): void
32
    {
33
        if (
34 12
            !$activity->is(Type::sourcesModified()) &&
35 12
            !$activity->is(Type::testsModified())
36
        ) {
37 2
            return;
38
        }
39
40 10
        $directory = $this->filesystem->mount($env->workingDirectory());
41
42 10
        if (!$directory->has('psalm.xml')) {
43 2
            return;
44
        }
45
46 8
        $output = $env->output();
47 8
        $error = $env->error();
48
49
        $process = $this
50 8
            ->processes
51 8
            ->execute(
52 8
                Command::foreground('vendor/bin/psalm')
53 8
                    ->withWorkingDirectory((string) $env->workingDirectory())
54
            );
55
        $process
56 8
            ->output()
57
            ->foreach(static function(Str $line, Output\Type $type) use ($output, $error): void {
58 4
                if ($type === Output\Type::output()) {
59 4
                    $output->write($line);
60
                } else {
61 4
                    $error->write($line);
62
                }
63 8
            });
64 8
        $process->wait();
65
66 8
        if ($env->arguments()->contains('--silent')) {
67 2
            return;
68
        }
69
70 6
        $successful = $process->exitCode()->isSuccessful();
71 6
        $text = 'Psalm : ';
72 6
        $text .= $successful ? 'ok' : 'failing';
73
74
        $this
75 6
            ->processes
76 6
            ->execute(
77 6
                Command::foreground('say')
78 6
                    ->withArgument($text)
79
            )
80 6
            ->wait();
81 6
    }
82
}
83