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.
Passed
Push — develop ( 7bdedc...1fa222 )
by Baptiste
02:15
created

DockerCompose   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 4
eloc 15
dl 0
loc 28
ccs 15
cts 15
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __invoke() 0 17 3
A __construct() 0 4 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\OperatingSystem\Filesystem;
13
use Innmind\Server\Control\Server\{
14
    Processes,
15
    Command,
16
};
17
18
final class DockerCompose implements Trigger
19
{
20
    private $filesystem;
21
    private $processes;
22
23 10
    public function __construct(Filesystem $filesystem, Processes $processes)
24
    {
25 10
        $this->filesystem = $filesystem;
26 10
        $this->processes = $processes;
27 10
    }
28
29 6
    public function __invoke(Activity $activity, Environment $env): void
30
    {
31 6
        if (!$activity->is(Type::start())) {
32 2
            return;
33
        }
34
35 4
        $project = $this->filesystem->mount($env->workingDirectory());
36
37 4
        if (!$project->has('docker-compose.yml')) {
38 2
            return;
39
        }
40
41 2
        $this->processes->execute(
42 2
            Command::foreground('docker-compose')
43 2
                ->withArgument('up')
44 2
                ->withShortOption('d')
45 2
                ->withWorkingDirectory((string) $env->workingDirectory())
46
        );
47 2
    }
48
}
49