Test Failed
Pull Request — master (#85)
by Keoghan
06:00
created

EventSubscriber::startForService()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 3
ccs 0
cts 2
cp 0
rs 10
cc 1
nc 1
nop 1
crap 2
1
<?php
2
3
4
namespace App\Support\DockerSync;
5
6
7
use App\Events\StartingPorter;
8
use App\Events\StoppingPorter;
9
use App\Events\BuiltDockerCompose;
10
use App\Events\StartingPorterService;
11
use App\Events\StoppingPorterService;
12
use App\Support\Console\ConsoleWriter;
13
14
class EventSubscriber
15
{
16
    /** @var DockerSync */
17
    protected $dockerSync;
18
19
    public function __construct(DockerSync $dockerSync)
20
    {
21
        $this->dockerSync = $dockerSync;
22
    }
23
24
    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

24
    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...
25
    {
26
        $this->dockerSync->startDaemon();
27
    }
28
29
    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

29
    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...
30
    {
31
        $this->dockerSync->startDaemon();
32
    }
33
34
    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

34
    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...
35
    {
36
        $this->dockerSync->stopDaemon();
37
    }
38
39
    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

39
    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...
40
    {
41
        $this->dockerSync->stopDaemon();
42
    }
43
44
    public function adaptDockerCompose(BuiltDockerCompose $event)
45
    {
46
        if ($this->dockerSync->isActive()) {
47
            app(ConsoleWriter::class)->info("Adapting DockerCompose YAML for DockerSync");
48
            $this->dockerSync->adjustDockerComposeSetup($event->filePath);
49
        }
50
    }
51
52
    /**
53
     * Register the listeners for the subscriber.
54
     *
55
     * @param  Illuminate\Events\Dispatcher  $events
0 ignored issues
show
Bug introduced by
The type App\Support\DockerSync\I...inate\Events\Dispatcher was not found. Did you mean Illuminate\Events\Dispatcher? If so, make sure to prefix the type with \.
Loading history...
56
     * @return void
57
     */
58
    public function subscribe($events)
59
    {
60
        $events->listen(StartingPorter::class, static::class."@startAll");
61
        $events->listen(StartingPorterService::class, static::class."@startForService");
62
        $events->listen(StoppingPorter::class, static::class."@stopAll");
63
        $events->listen(StoppingPorterService::class, static::class."@stopForService");
64
        $events->listen(BuiltDockerCompose::class, static::class."@adaptDockerCompose");
65
    }
66
}
67