Passed
Pull Request — master (#2138)
by Janko
35:10 queued 23:45
created

SpacecraftCondition::setShield()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 1
dl 0
loc 5
rs 10
c 0
b 0
f 0
ccs 0
cts 3
cp 0
crap 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Stu\Orm\Entity;
6
7
use Doctrine\ORM\Mapping\Column;
8
use Doctrine\ORM\Mapping\Entity;
9
use Doctrine\ORM\Mapping\Id;
10
use Doctrine\ORM\Mapping\JoinColumn;
11
use Doctrine\ORM\Mapping\OneToOne;
12
use Doctrine\ORM\Mapping\Table;
13
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...
14
use Stu\Component\Spacecraft\SpacecraftStateEnum;
15
use Stu\Component\Spacecraft\Trait\SpacecraftHullColorStyleTrait;
16
17
#[Table(name: 'stu_spacecraft_condition')]
18
#[Entity]
19
class SpacecraftCondition implements SpacecraftConditionInterface
20
{
21
    use SpacecraftHullColorStyleTrait;
0 ignored issues
show
Bug introduced by
The trait Stu\Component\Spacecraft...raftHullColorStyleTrait requires the property $value which is not provided by Stu\Orm\Entity\SpacecraftCondition.
Loading history...
22
23
    #[Column(type: 'integer', length: 6)]
24
    private int $hull = 0;
25
26
    #[Column(type: 'integer', length: 6)]
27
    private int $shield = 0;
28
29
    #[Column(type: 'boolean')]
30
    private bool $is_disabled = false;
31
32
    #[Column(type: 'smallint', enumType: SpacecraftStateEnum::class)]
33
    private SpacecraftStateEnum $state = SpacecraftStateEnum::NONE;
34
35
    #[Id]
36
    #[OneToOne(targetEntity: 'Spacecraft', inversedBy: 'condition')]
37
    #[JoinColumn(name: 'spacecraft_id', referencedColumnName: 'id', onDelete: 'CASCADE')]
38
    private SpacecraftInterface $spacecraft;
39
40
    // transitive fields
41
    private bool $is_destroyed = false;
42
43 3
    public function __construct(SpacecraftInterface $spacecraft)
44
    {
45 3
        $this->spacecraft = $spacecraft;
46
    }
47
48 3
    #[Override]
49
    public function getSpacecraft(): SpacecraftInterface
50
    {
51 3
        return $this->spacecraft;
52
    }
53
54 15
    #[Override]
55
    public function getHull(): int
56
    {
57 15
        return $this->hull;
58
    }
59
60
    #[Override]
61
    public function setHull(int $hull): SpacecraftConditionInterface
62
    {
63
        $this->hull = $hull;
64
        return $this;
65
    }
66
67
    #[Override]
68
    public function changeHull(int $amount): SpacecraftConditionInterface
69
    {
70
        $this->hull += $amount;
71
        return $this;
72
    }
73
74 9
    #[Override]
75
    public function getShield(): int
76
    {
77 9
        return $this->shield;
78
    }
79
80
    #[Override]
81
    public function setShield(int $shield): SpacecraftConditionInterface
82
    {
83
        $this->shield = $shield;
84
        return $this;
85
    }
86
87
    #[Override]
88
    public function changeShield(int $amount): SpacecraftConditionInterface
89
    {
90
        $this->shield += $amount;
91
        return $this;
92
    }
93
94 2
    #[Override]
95
    public function isDestroyed(): bool
96
    {
97 2
        return $this->is_destroyed;
98
    }
99
100
    #[Override]
101
    public function setIsDestroyed(bool $isDestroyed): SpacecraftConditionInterface
102
    {
103
        $this->is_destroyed = $isDestroyed;
104
        return $this;
105
    }
106
107
    #[Override]
108
    public function isDisabled(): bool
109
    {
110
        return $this->is_disabled;
111
    }
112
113
    #[Override]
114
    public function setDisabled(bool $isDisabled): SpacecraftConditionInterface
115
    {
116
        $this->is_disabled = $isDisabled;
117
        return $this;
118
    }
119
120 5
    #[Override]
121
    public function getState(): SpacecraftStateEnum
122
    {
123 5
        return $this->state;
124
    }
125
126
    #[Override]
127
    public function setState(SpacecraftStateEnum $state): SpacecraftConditionInterface
128
    {
129
        $this->state = $state;
130
        return $this;
131
    }
132
133
    #[Override]
134
    public function isUnderRepair(): bool
135
    {
136
        return $this->getState()->isRepairState();
137
    }
138
139
    #[Override]
140
    public function isUnderRetrofit(): bool
141
    {
142
        return $this->getState() === SpacecraftStateEnum::RETROFIT;
143
    }
144
}
145