Passed
Push — master ( e47c8e...e58eed )
by Keoghan
07:56
created

EventSubscriber::subscribe()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 5
c 1
b 0
f 0
dl 0
loc 7
ccs 6
cts 6
cp 1
rs 10
cc 1
nc 1
nop 1
crap 1
1
<?php
2
3
namespace App\Support\DockerSync;
4
5
use App\Events\BuiltDockerCompose;
6
use App\Events\StartingPorter;
7
use App\Events\StartingPorterService;
8
use App\Events\StoppingPorter;
9
use App\Events\StoppingPorterService;
10
use App\Support\Console\ConsoleWriter;
11
12
class EventSubscriber
13
{
14
    /** @var DockerSync */
15
    protected $dockerSync;
16
17 191
    public function __construct(DockerSync $dockerSync)
18
    {
19 191
        $this->dockerSync = $dockerSync;
20 191
    }
21
22 1
    public function startAll(StartingPorter $event)
0 ignored issues
show
Unused Code introduced by
The parameter $event is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

22
    public function startAll(/** @scrutinizer ignore-unused */ StartingPorter $event)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
23
    {
24 1
        $this->dockerSync->startDaemon();
25 1
    }
26
27 3
    public function startForService(StartingPorterService $event)
0 ignored issues
show
Unused Code introduced by
The parameter $event is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

27
    public function startForService(/** @scrutinizer ignore-unused */ StartingPorterService $event)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
28
    {
29 3
        $this->dockerSync->startDaemon();
30 3
    }
31
32 1
    public function stopAll(StoppingPorter $event)
0 ignored issues
show
Unused Code introduced by
The parameter $event is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

32
    public function stopAll(/** @scrutinizer ignore-unused */ StoppingPorter $event)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
33
    {
34 1
        $this->dockerSync->stopDaemon();
35 1
    }
36
37 3
    public function stopForService(StoppingPorterService $event)
0 ignored issues
show
Unused Code introduced by
The parameter $event is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

37
    public function stopForService(/** @scrutinizer ignore-unused */ StoppingPorterService $event)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
38
    {
39 3
        $this->dockerSync->stopDaemon();
40 3
    }
41
42 7
    public function adaptDockerCompose(BuiltDockerCompose $event)
43
    {
44 7
        if ($this->dockerSync->isActive()) {
45
            app(ConsoleWriter::class)->info('Adapting DockerCompose YAML for DockerSync');
46
            $this->dockerSync->adjustDockerComposeSetup($event->filePath);
47
        }
48 7
    }
49
50
    /**
51
     * Register the listeners for the subscriber.
52
     *
53
     * @param \Illuminate\Events\Dispatcher $events
54
     *
55
     * @return void
56
     */
57 191
    public function subscribe($events)
58
    {
59 191
        $events->listen(StartingPorter::class, static::class.'@startAll');
60 191
        $events->listen(StartingPorterService::class, static::class.'@startForService');
61 191
        $events->listen(StoppingPorter::class, static::class.'@stopAll');
62 191
        $events->listen(StoppingPorterService::class, static::class.'@stopForService');
63 191
        $events->listen(BuiltDockerCompose::class, static::class.'@adaptDockerCompose');
64 191
    }
65
}
66