Passed
Pull Request — master (#1969)
by Janko
22:34 queued 10:03
created

Ship   A

Complexity

Total Complexity 27

Size/Duplication

Total Lines 188
Duplicated Lines 0 %

Test Coverage

Coverage 50%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 81
dl 0
loc 188
ccs 30
cts 60
cp 0.5
rs 10
c 1
b 0
f 0
wmc 27

24 Methods

Rating   Name   Duplication   Size   Complexity  
A isFleetLeader() 0 4 1
A setFleetId() 0 5 1
A isTractored() 0 4 1
A setDockedTo() 0 5 1
A canBuildConstruction() 0 4 1
A getType() 0 4 1
A getTransferEntityType() 0 4 1
A isUnderRetrofit() 0 4 1
A getIsFleetLeader() 0 4 2
A setDockedToId() 0 5 1
A setFleet() 0 5 1
A dockedOnTradePost() 0 7 2
A getFleet() 0 4 1
A setIsFleetLeader() 0 5 1
A getMiningQueue() 0 4 1
A getColonyShipQueue() 0 4 1
A getAstroState() 0 4 1
A getDockedTo() 0 4 1
A getFleetId() 0 4 1
A setColonyShipQueue() 0 5 1
A isWarped() 0 10 2
A getTractoringSpacecraft() 0 4 1
A setTractoringSpacecraft() 0 5 1
A isBussardCollectorHealthy() 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\JoinColumn;
10
use Doctrine\ORM\Mapping\ManyToOne;
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\SpacecraftTypeEnum;
16
use Stu\Component\Spacecraft\System\SpacecraftSystemTypeEnum;
17
use Stu\Component\Station\StationUtility;
18
use Stu\Lib\Transfer\TransferEntityTypeEnum;
19
use Stu\Orm\Repository\ShipRepository;
20
21
#[Table(name: 'stu_ship')]
22
#[Entity(repositoryClass: ShipRepository::class)]
23
class Ship extends Spacecraft implements ShipInterface
24
{
25
    #[Column(type: 'integer', nullable: true)]
26
    private ?int $fleet_id = null;
27
28
    #[Column(type: 'integer', nullable: true)]
29
    private ?int $docked_to_id = null;
30
31
    #[Column(type: 'boolean')]
32
    private bool $is_fleet_leader = false;
33
34
    #[ManyToOne(targetEntity: 'Fleet', inversedBy: 'ships')]
35
    #[JoinColumn(name: 'fleet_id', referencedColumnName: 'id')]
36
    private ?FleetInterface $fleet = null;
37
38
    #[ManyToOne(targetEntity: 'Station', inversedBy: 'dockedShips')]
39
    #[JoinColumn(name: 'docked_to_id', referencedColumnName: 'id')]
40
    private ?StationInterface $dockedTo = null;
41
42
    #[OneToOne(targetEntity: 'Spacecraft', mappedBy: 'tractoredShip')]
43
    private ?SpacecraftInterface $tractoringSpacecraft = null;
44
45
    #[OneToOne(targetEntity: 'MiningQueue', mappedBy: 'ship')]
46
    private ?MiningQueueInterface $miningqueue = null;
47
48
    #[OneToOne(targetEntity: 'ColonyShipQueue', mappedBy: 'ship')]
49
    private ?ColonyShipQueueInterface $colonyShipQueue = null;
50
51 19
    #[Override]
52
    public function getType(): SpacecraftTypeEnum
53
    {
54 19
        return SpacecraftTypeEnum::SHIP;
55
    }
56
57
    #[Override]
58
    public function getFleetId(): ?int
59
    {
60
        return $this->fleet_id;
61
    }
62
63
    #[Override]
64
    public function setFleetId(?int $fleetId): ShipInterface
65
    {
66
        $this->fleet_id = $fleetId;
67
        return $this;
68
    }
69
70
    #[Override]
71
    public function isUnderRetrofit(): bool
72
    {
73
        return $this->getState() === SpacecraftStateEnum::SHIP_STATE_RETROFIT;
74
    }
75
76 3
    #[Override]
77
    public function getIsFleetLeader(): bool
78
    {
79 3
        return $this->getFleet() !== null && $this->is_fleet_leader;
80
    }
81
82
    #[Override]
83
    public function setIsFleetLeader(bool $isFleetLeader): ShipInterface
84
    {
85
        $this->is_fleet_leader = $isFleetLeader;
86
        return $this;
87
    }
88
89 10
    #[Override]
90
    public function getFleet(): ?FleetInterface
91
    {
92 10
        return $this->fleet;
93
    }
94
95
    #[Override]
96
    public function setFleet(?FleetInterface $fleet): ShipInterface
97
    {
98
        $this->fleet = $fleet;
99
        return $this;
100
    }
101
102 3
    #[Override]
103
    public function isFleetLeader(): bool
104
    {
105 3
        return $this->getIsFleetLeader();
106
    }
107
108 1
    #[Override]
109
    public function isTractored(): bool
110
    {
111 1
        return $this->getTractoringSpacecraft() !== null;
112
    }
113
114 1
    #[Override]
115
    public function dockedOnTradePost(): bool
116
    {
117 1
        $dockedTo = $this->getDockedTo();
118
119 1
        return $dockedTo !== null
120 1
            && $dockedTo->getTradePost() !== null;
121
    }
122
123 4
    #[Override]
124
    public function getTractoringSpacecraft(): ?SpacecraftInterface
125
    {
126 4
        return $this->tractoringSpacecraft;
127
    }
128
129
    #[Override]
130
    public function setTractoringSpacecraft(?SpacecraftInterface $spacecraft): ShipInterface
131
    {
132
        $this->tractoringSpacecraft = $spacecraft;
133
        return $this;
134
    }
135
136 16
    #[Override]
137
    public function getDockedTo(): ?StationInterface
138
    {
139 16
        return $this->dockedTo;
140
    }
141
142
    #[Override]
143
    public function setDockedTo(?StationInterface $dockedTo): ShipInterface
144
    {
145
        $this->dockedTo = $dockedTo;
146
        return $this;
147
    }
148
149
    #[Override]
150
    public function setDockedToId(?int $dockedToId): ShipInterface
151
    {
152
        $this->docked_to_id = $dockedToId;
153
        return $this;
154
    }
155
156 1
    #[Override]
157
    public function canBuildConstruction(): bool
158
    {
159 1
        return StationUtility::canShipBuildConstruction($this);
160
    }
161
162 4
    #[Override]
163
    public function isWarped(): bool
164
    {
165 4
        $tractoringShip = $this->getTractoringSpacecraft();
166
167 4
        if ($tractoringShip !== null) {
168
            return $tractoringShip->getWarpDriveState();
169
        }
170
171 4
        return parent::getWarpDriveState();
172
    }
173
174 1
    #[Override]
175
    public function getAstroState(): bool
176
    {
177 1
        return $this->getSystemState(SpacecraftSystemTypeEnum::SYSTEM_ASTRO_LABORATORY);
178
    }
179
180 1
    #[Override]
181
    public function isBussardCollectorHealthy(): bool
182
    {
183 1
        return $this->isSystemHealthy(SpacecraftSystemTypeEnum::SYSTEM_BUSSARD_COLLECTOR);
184
    }
185
186
    #[Override]
187
    public function getMiningQueue(): ?MiningQueueInterface
188
    {
189
        return $this->miningqueue;
190
    }
191
192
    #[Override]
193
    public function getColonyShipQueue(): ?ColonyShipQueueInterface
194
    {
195
        return $this->colonyShipQueue;
196
    }
197
198
    #[Override]
199
    public function setColonyShipQueue(?ColonyShipQueueInterface $queue): ShipInterface
200
    {
201
        $this->colonyShipQueue = $queue;
202
        return $this;
203
    }
204
205 16
    #[Override]
206
    public function getTransferEntityType(): TransferEntityTypeEnum
207
    {
208 16
        return TransferEntityTypeEnum::SHIP;
209
    }
210
}
211