Passed
Push — dev ( 98511f...00baf5 )
by Janko
15:17
created

SpacecraftSystemExistenceTrait   A

Complexity

Total Complexity 11

Size/Duplication

Total Lines 49
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 13
c 0
b 0
f 0
dl 0
loc 49
ccs 20
cts 20
cp 1
rs 10
wmc 11

9 Methods

Rating   Name   Duplication   Size   Complexity  
A hasUplink() 0 3 1
A hasReactor() 0 5 3
A hasTorpedo() 0 3 1
A hasNbsLss() 0 3 1
A hasPhaser() 0 3 1
A hasWarpdrive() 0 3 1
A hasShuttleRamp() 0 3 1
A hasCloak() 0 3 1
A hasSpacecraftSystem() 0 3 1
1
<?php
2
3
namespace Stu\Component\Spacecraft\Trait;
4
5
use Stu\Component\Spacecraft\System\SpacecraftSystemTypeEnum;
6
7
trait SpacecraftSystemExistenceTrait
8
{
9
    use SpacecraftTrait;
10
11 38
    public function hasSpacecraftSystem(SpacecraftSystemTypeEnum $type): bool
12
    {
13 38
        return $this->getThis()->getSystems()->containsKey($type->value);
14
    }
15
16 4
    public function hasPhaser(): bool
17
    {
18 4
        return $this->hasSpacecraftSystem(SpacecraftSystemTypeEnum::PHASER);
19
    }
20
21 6
    public function hasTorpedo(): bool
22
    {
23 6
        return $this->hasSpacecraftSystem(SpacecraftSystemTypeEnum::TORPEDO);
24
    }
25
26 4
    public function hasCloak(): bool
27
    {
28 4
        return $this->hasSpacecraftSystem(SpacecraftSystemTypeEnum::CLOAK);
29
    }
30
31 4
    public function hasShuttleRamp(): bool
32
    {
33 4
        return $this->hasSpacecraftSystem(SpacecraftSystemTypeEnum::SHUTTLE_RAMP);
34
    }
35
36 6
    public function hasWarpdrive(): bool
37
    {
38 6
        return $this->hasSpacecraftSystem(SpacecraftSystemTypeEnum::WARPDRIVE);
39
    }
40
41 1
    public function hasReactor(): bool
42
    {
43 1
        return $this->hasSpacecraftSystem(SpacecraftSystemTypeEnum::WARPCORE) ||
44 1
            $this->hasSpacecraftSystem(SpacecraftSystemTypeEnum::FUSION_REACTOR) ||
45 1
            $this->hasSpacecraftSystem(SpacecraftSystemTypeEnum::SINGULARITY_REACTOR);
46
    }
47
48 2
    public function hasNbsLss(): bool
49
    {
50 2
        return $this->hasSpacecraftSystem(SpacecraftSystemTypeEnum::LSS);
51
    }
52
53 7
    public function hasUplink(): bool
54
    {
55 7
        return $this->hasSpacecraftSystem(SpacecraftSystemTypeEnum::UPLINK);
56
    }
57
}
58