Passed
Push — dev ( 3fd410...aa33df )
by Janko
13:32
created

ComputerSystemData::getFlightDirection()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
ccs 0
cts 2
cp 0
crap 2
rs 10
c 1
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Stu\Component\Spacecraft\System\Data;
6
7
use Override;
0 ignored issues
show
Bug introduced by
The type Override was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
8
use Stu\Component\Map\DirectionEnum;
9
use Stu\Component\Spacecraft\SpacecraftAlertStateEnum;
10
use Stu\Component\Spacecraft\System\SpacecraftSystemTypeEnum;
11
12
class ComputerSystemData extends AbstractSystemData
13
{
14
    public int $hitChance = 0;
15
    public int $evadeChance = 0;
16
    public bool $isInEmergency = false;
17
    public DirectionEnum $flightDirection = DirectionEnum::NON;
18
    public SpacecraftAlertStateEnum $alertState = SpacecraftAlertStateEnum::ALERT_GREEN;
19
20
    #[Override]
21
    public function getSystemType(): SpacecraftSystemTypeEnum
22
    {
23
        return SpacecraftSystemTypeEnum::COMPUTER;
24
    }
25
26 1
    public function getHitChance(): int
27
    {
28 1
        return (int) (ceil($this->hitChance
29 1
            * $this->spacecraft->getSpacecraftSystem(SpacecraftSystemTypeEnum::COMPUTER)->getStatus() / 100));
30
    }
31
32
    public function setHitChance(int $hitChance): ComputerSystemData
33
    {
34
        $this->hitChance = $hitChance;
35
        return $this;
36
    }
37
38 1
    public function getEvadeChance(): int
39
    {
40 1
        if (!$this->spacecraft->hasSpacecraftSystem(SpacecraftSystemTypeEnum::IMPULSEDRIVE)) {
41
            return $this->evadeChance;
42
        }
43
44 1
        return (int) (ceil($this->evadeChance
45 1
            * $this->spacecraft->getSpacecraftSystem(SpacecraftSystemTypeEnum::IMPULSEDRIVE)->getStatus() / 100));
46
    }
47
48
    public function setEvadeChance(int $evadeChance): ComputerSystemData
49
    {
50
        $this->evadeChance = $evadeChance;
51
        return $this;
52
    }
53
54 1
    public function isInEmergency(): bool
55
    {
56 1
        return $this->isInEmergency;
57
    }
58
59
    public function setIsInEmergency(bool $isInEmergency): ComputerSystemData
60
    {
61
        $this->isInEmergency = $isInEmergency;
62
        return $this;
63
    }
64
65
    public function getFlightDirection(): DirectionEnum
66
    {
67
        return $this->flightDirection;
68
    }
69
70
    public function setFlightDirection(DirectionEnum $direction): ComputerSystemData
71
    {
72
        $this->flightDirection = $direction;
73
        return $this;
74
    }
75
76 3
    public function getAlertState(): SpacecraftAlertStateEnum
77
    {
78 3
        return $this->alertState;
79
    }
80
81
    public function setAlertState(SpacecraftAlertStateEnum $alertState): ComputerSystemData
82
    {
83
        $this->alertState = $alertState;
84
        return $this;
85
    }
86
87 1
    public function isAlertGreen(): bool
88
    {
89 1
        return $this->alertState === SpacecraftAlertStateEnum::ALERT_GREEN;
90
    }
91
92
    public function setAlertStateGreen(): ComputerSystemData
93
    {
94
        return $this->setAlertState(SpacecraftAlertStateEnum::ALERT_GREEN);
95
    }
96
}
97