Passed
Push — dev ( b01017...737777 )
by Janko
05:10
created

SpacecraftSystemWrapper::isHealthy()   A

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 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
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 2
    public function __construct(
13
        Spacecraft $spacecraft,
14
        private SpacecraftSystemTypeEnum $type
15
    ) {
16 2
        $this->spacecraftSystem = $spacecraft->getSpacecraftSystem($type);
17
    }
18
19 1
    public function get(): SpacecraftSystem
20
    {
21 1
        return $this->spacecraftSystem;
22
    }
23
24 2
    public function isActivated(): bool
25
    {
26 2
        return $this->spacecraftSystem->getMode()->isActivated();
27
    }
28
29 1
    public function isHealthy(): bool
30
    {
31 1
        return $this->spacecraftSystem->isHealthy();
32
    }
33
34 2
    public function getGenericTemplate(): ?string
35
    {
36 2
        return $this->type->getGenericTemplate();
37
    }
38
39 2
    public function getIcon(): string
40
    {
41 2
        return $this->type->getIcon();
42
    }
43
44 2
    public function getDescription(): string
45
    {
46 2
        return $this->type->getDescription();
47
    }
48
49 2
    public function getPreActionJs(): ?string
50
    {
51 2
        return $this->type->isReloadOnActivation()
52
            ? sprintf('setAjaxMandatory(true);')
53 2
            : null;
54
    }
55
}
56