Passed
Push — dev ( 117aec...fd7324 )
by Janko
15:18
created

SpacecraftStateTrait::isTractoring()   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 SpacecraftStateTrait
8
{
9
    use SpacecraftTrait;
10
    use SpacecraftSystemExistenceTrait;
11
12 2
    public function isWarped(): bool
13
    {
14 2
        return $this->getThis()->getWarpDriveState();
15
    }
16
17
    public function getHealthPercentage(): float
18
    {
19
        $self = $this->getThis();
20
        $condition = $self->getCondition();
21
22
        return ($condition->getHull() + $condition->getShield())
23
            / ($self->getMaxHull() + $self->getMaxShield(true)) * 100;
24
    }
25
26 1
    public function isTractoring(): bool
27
    {
28 1
        return $this->getThis()->getTractoredShip() !== null;
29
    }
30
31 1
    public function isWarpPossible(): bool
32
    {
33 1
        return $this->hasSpacecraftSystem(SpacecraftSystemTypeEnum::WARPDRIVE) && $this->getSystem() === null;
0 ignored issues
show
Bug introduced by
It seems like getSystem() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

33
        return $this->hasSpacecraftSystem(SpacecraftSystemTypeEnum::WARPDRIVE) && $this->/** @scrutinizer ignore-call */ getSystem() === null;
Loading history...
34
    }
35
36 1
    public function displayNbsActions(): bool
37
    {
38 1
        return !$this->getThis()->isCloaked()
39 1
            && !$this->getThis()->isWarped();
40
    }
41
}
42