Passed
Push — master ( 41c1e2...7e39ad )
by Nico
17:44 queued 08:39
created

SpacecraftSystemWrapper::getPostActionJs()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 2.0625

Importance

Changes 0
Metric Value
cc 2
eloc 3
nc 2
nop 0
dl 0
loc 5
ccs 3
cts 4
cp 0.75
crap 2.0625
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Stu\Component\Spacecraft\System;
4
5
use Stu\Orm\Entity\Spacecraft;
6
use Stu\Orm\Entity\SpacecraftSystem;
7
8
class SpacecraftSystemWrapper
9
{
10
    private SpacecraftSystem $spacecraftSystem;
11
12 1
    public function __construct(
13
        Spacecraft $spacecraft,
14
        private SpacecraftSystemTypeEnum $type
15
    ) {
16 1
        $this->spacecraftSystem = $spacecraft->getSpacecraftSystem($type);
17
    }
18
19
    public function get(): SpacecraftSystem
20
    {
21
        return $this->spacecraftSystem;
22
    }
23
24 1
    public function isActivated(): bool
25
    {
26 1
        return $this->spacecraftSystem->getMode()->isActivated();
27
    }
28
29
    public function isHealthy(): bool
30
    {
31
        return $this->spacecraftSystem->isHealthy();
32
    }
33
34 1
    public function getGenericTemplate(): ?string
35
    {
36 1
        return $this->type->getGenericTemplate();
37
    }
38
39 1
    public function getIcon(): string
40
    {
41 1
        return $this->type->getIcon();
42
    }
43
44 1
    public function getDescription(): string
45
    {
46 1
        return $this->type->getDescription();
47
    }
48
49 1
    public function getPreActionJs(): ?string
50
    {
51 1
        return $this->type->isReloadOnActivation()
52
            ? sprintf('setAjaxMandatory(true);')
53 1
            : null;
54
    }
55
56 1
    public function getPostActionJs(): ?string
57
    {
58 1
        return $this->type->isReloadOnActivation()
59
            ? sprintf('showSystemSettingsWindow("%s");setAjaxMandatory(false);', $this->type->name)
0 ignored issues
show
Bug introduced by
The property name does not seem to exist on Stu\Component\Spacecraft...pacecraftSystemTypeEnum.
Loading history...
60 1
            : null;
61
    }
62
}
63