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

SpacecraftSystemStateTrait   A

Complexity

Total Complexity 15

Size/Duplication

Total Lines 72
Duplicated Lines 0 %

Test Coverage

Coverage 92.86%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 18
c 1
b 0
f 0
dl 0
loc 72
ccs 26
cts 28
cp 0.9286
rs 10
wmc 15

13 Methods

Rating   Name   Duplication   Size   Complexity  
A getTorpedoState() 0 3 1
A isShielded() 0 3 1
A getRPGModuleState() 0 3 1
A getSystemState() 0 7 2
A getLss() 0 3 1
A getNbs() 0 3 1
A getTachyonState() 0 3 1
A getImpulseState() 0 3 1
A getPhaserState() 0 3 1
A getWarpDriveState() 0 3 1
A isCloaked() 0 3 1
A getSubspaceState() 0 3 1
A hasActiveWeapon() 0 3 2
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