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

SpacecraftSystemHealthTrait   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Test Coverage

Coverage 71.43%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 11
c 1
b 0
f 0
dl 0
loc 37
ccs 10
cts 14
cp 0.7143
rs 10
wmc 7

6 Methods

Rating   Name   Duplication   Size   Complexity  
A isShuttleRampHealthy() 0 3 1
A isWebEmitterHealthy() 0 3 1
A isMatrixScannerHealthy() 0 3 1
A isTorpedoStorageHealthy() 0 3 1
A isDeflectorHealthy() 0 3 1
A isSystemHealthy() 0 7 2
1
<?php
2
3
namespace Stu\Component\Spacecraft\Trait;
4
5
use Stu\Component\Spacecraft\System\SpacecraftSystemTypeEnum;
6
7
trait SpacecraftSystemHealthTrait
8
{
9
    use SpacecraftTrait;
10
    use HasSpacecraftSystemTrait;
11
12 17
    public function isSystemHealthy(SpacecraftSystemTypeEnum $type): bool
13
    {
14 17
        if (!$this->hasSpacecraftSystem($type)) {
15 14
            return false;
16
        }
17
18 5
        return $this->getSpacecraftSystem($type)->isHealthy();
19
    }
20
21
    public function isDeflectorHealthy(): bool
22
    {
23
        return $this->isSystemHealthy(SpacecraftSystemTypeEnum::DEFLECTOR);
24
    }
25
26
    public function isMatrixScannerHealthy(): bool
27
    {
28
        return $this->isSystemHealthy(SpacecraftSystemTypeEnum::MATRIX_SCANNER);
29
    }
30
31 10
    public function isTorpedoStorageHealthy(): bool
32
    {
33 10
        return $this->isSystemHealthy(SpacecraftSystemTypeEnum::TORPEDO_STORAGE);
34
    }
35
36 1
    public function isShuttleRampHealthy(): bool
37
    {
38 1
        return $this->isSystemHealthy(SpacecraftSystemTypeEnum::SHUTTLE_RAMP);
39
    }
40
41 1
    public function isWebEmitterHealthy(): bool
42
    {
43 1
        return $this->isSystemHealthy(SpacecraftSystemTypeEnum::THOLIAN_WEB);
44
    }
45
}
46