Passed
Push — dev ( c12b3a...6ad196 )
by Janko
24:31 queued 10:07
created

SpacecraftSystemStateTrait::getSubspaceState()   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 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
1
<?php
2
3
namespace Stu\Component\Spacecraft\Trait;
4
5
use Stu\Component\Spacecraft\System\SpacecraftSystemTypeEnum;
6
7
trait SpacecraftSystemStateTrait
8
{
9
    use SpacecraftTrait;
10
    use HasSpacecraftSystemTrait;
11
12 20
    public function isShielded(): bool
13
    {
14 20
        return $this->getSystemState(SpacecraftSystemTypeEnum::SHIELDS);
15
    }
16
17 7
    public function getNbs(): bool
18
    {
19 7
        return $this->getSystemState(SpacecraftSystemTypeEnum::NBS);
20
    }
21
22 6
    public function getLss(): bool
23
    {
24 6
        return $this->getSystemState(SpacecraftSystemTypeEnum::LSS);
25
    }
26
27 32
    public function isCloaked(): bool
28
    {
29 32
        return $this->getSystemState(SpacecraftSystemTypeEnum::CLOAK);
30
    }
31
32 4
    public function getImpulseState(): bool
33
    {
34 4
        return $this->getSystemState(SpacecraftSystemTypeEnum::IMPULSEDRIVE);
35
    }
36
37 6
    public function getWarpDriveState(): bool
38
    {
39 6
        return $this->getSystemState(SpacecraftSystemTypeEnum::WARPDRIVE);
40
    }
41
42 3
    public function getPhaserState(): bool
43
    {
44 3
        return $this->getSystemState(SpacecraftSystemTypeEnum::PHASER);
45
    }
46
47 1
    public function getTorpedoState(): bool
48
    {
49 1
        return $this->getSystemState(SpacecraftSystemTypeEnum::TORPEDO);
50
    }
51
52 2
    public function getTachyonState(): bool
53
    {
54 2
        return $this->getSystemState(SpacecraftSystemTypeEnum::TACHYON_SCANNER);
55
    }
56
57 1
    public function getSubspaceState(): bool
58
    {
59 1
        return $this->getSystemState(SpacecraftSystemTypeEnum::SUBSPACE_SCANNER);
60
    }
61
62
    public function getRPGModuleState(): bool
63
    {
64
        return $this->getSystemState(SpacecraftSystemTypeEnum::RPG_MODULE);
65
    }
66
67 1
    public function hasActiveWeapon(): bool
68
    {
69 1
        return $this->getPhaserState() || $this->getTorpedoState();
70
    }
71
72 35
    public function getSystemState(SpacecraftSystemTypeEnum $type): bool
73
    {
74 35
        if (!$this->hasSpacecraftSystem($type)) {
75 32
            return false;
76
        }
77
78 13
        return $this->getSpacecraftSystem($type)->getMode()->isActivated();
79
    }
80
}
81