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

SpacecraftCondition   A

Complexity

Total Complexity 15

Size/Duplication

Total Lines 123
Duplicated Lines 0 %

Test Coverage

Coverage 21.05%

Importance

Changes 0
Metric Value
eloc 55
dl 0
loc 123
rs 10
c 0
b 0
f 0
ccs 8
cts 38
cp 0.2105
wmc 15

15 Methods

Rating   Name   Duplication   Size   Complexity  
A getShield() 0 4 1
A getState() 0 4 1
A setState() 0 5 1
A setHull() 0 5 1
A isDisabled() 0 4 1
A setIsDestroyed() 0 5 1
A changeShield() 0 5 1
A changeHull() 0 5 1
A setDisabled() 0 5 1
A getHull() 0 4 1
A isDestroyed() 0 4 1
A setShield() 0 5 1
A setSpacecraft() 0 6 1
A isUnderRepair() 0 4 1
A isUnderRetrofit() 0 4 1
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
    #[Override]
44
    public function setSpacecraft(SpacecraftInterface $spacecraft): SpacecraftConditionInterface
45
    {
46
        $this->spacecraft = $spacecraft;
47
48
        return $this;
49
    }
50
51 15
    #[Override]
52
    public function getHull(): int
53
    {
54 15
        return $this->hull;
55
    }
56
57
    #[Override]
58
    public function setHull(int $hull): SpacecraftConditionInterface
59
    {
60
        $this->hull = $hull;
61
        return $this;
62
    }
63
64
    #[Override]
65
    public function changeHull(int $amount): SpacecraftConditionInterface
66
    {
67
        $this->hull += $amount;
68
        return $this;
69
    }
70
71 9
    #[Override]
72
    public function getShield(): int
73
    {
74 9
        return $this->shield;
75
    }
76
77
    #[Override]
78
    public function setShield(int $shield): SpacecraftConditionInterface
79
    {
80
        $this->shield = $shield;
81
        return $this;
82
    }
83
84
    #[Override]
85
    public function changeShield(int $amount): SpacecraftConditionInterface
86
    {
87
        $this->shield += $amount;
88
        return $this;
89
    }
90
91 2
    #[Override]
92
    public function isDestroyed(): bool
93
    {
94 2
        return $this->is_destroyed;
95
    }
96
97
    #[Override]
98
    public function setIsDestroyed(bool $isDestroyed): SpacecraftConditionInterface
99
    {
100
        $this->is_destroyed = $isDestroyed;
101
        return $this;
102
    }
103
104
    #[Override]
105
    public function isDisabled(): bool
106
    {
107
        return $this->is_disabled;
108
    }
109
110
    #[Override]
111
    public function setDisabled(bool $isDisabled): SpacecraftConditionInterface
112
    {
113
        $this->is_disabled = $isDisabled;
114
        return $this;
115
    }
116
117 5
    #[Override]
118
    public function getState(): SpacecraftStateEnum
119
    {
120 5
        return $this->state;
121
    }
122
123
    #[Override]
124
    public function setState(SpacecraftStateEnum $state): SpacecraftConditionInterface
125
    {
126
        $this->state = $state;
127
        return $this;
128
    }
129
130
    #[Override]
131
    public function isUnderRepair(): bool
132
    {
133
        return $this->getState()->isRepairState();
134
    }
135
136
    #[Override]
137
    public function isUnderRetrofit(): bool
138
    {
139
        return $this->getState() === SpacecraftStateEnum::RETROFIT;
140
    }
141
}
142