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.

Tests::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 1
c 1
b 0
f 1
dl 0
loc 3
ccs 2
cts 2
cp 1
rs 10
cc 1
nc 1
nop 1
crap 1
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\Immutable\Str;
18
19
final class Tests implements Trigger
20
{
21
    private $processes;
22
23 14
    public function __construct(Processes $processes)
24
    {
25 14
        $this->processes = $processes;
26 14
    }
27
28 10
    public function __invoke(Activity $activity, Environment $env): void
29
    {
30
        if (
31 10
            !$activity->is(Type::sourcesModified()) &&
32 10
            !$activity->is(Type::testsModified())
33
        ) {
34 2
            return;
35
        }
36
37 8
        $output = $env->output();
38 8
        $error = $env->error();
39
40
        $process = $this
41 8
            ->processes
42 8
            ->execute(
43 8
                Command::foreground('vendor/bin/phpunit')
44 8
                    ->withOption('colors', 'always')
45 8
                    ->withWorkingDirectory((string) $env->workingDirectory())
46
            );
47
        $process
48 8
            ->output()
49
            ->foreach(static function(Str $line, Output\Type $type) use ($output, $error): void {
50 4
                if ($type === Output\Type::output()) {
51 4
                    $output->write($line);
52
                } else {
53 4
                    $error->write($line);
54
                }
55 8
            });
56 8
        $process->wait();
57
58 8
        if ($env->arguments()->contains('--silent')) {
59 2
            return;
60
        }
61
62 6
        $successful = $process->exitCode()->isSuccessful();
63 6
        $text = 'PHPUnit : ';
64 6
        $text .= $successful ? 'ok' : 'failing';
65
66
        $this
67 6
            ->processes
68 6
            ->execute(
69 6
                Command::foreground('say')
70 6
                    ->withArgument($text)
71
            )
72 6
            ->wait();
73 6
    }
74
}
75