Passed
Push — master ( ad7b81...1c3353 )
by Janko
35:52
created

StarSystem::getAstronomicalEntries()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 4
ccs 0
cts 2
cp 0
crap 2
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Stu\Orm\Entity;
6
7
use Doctrine\Common\Collections\ArrayCollection;
8
use Doctrine\Common\Collections\Collection;
9
use Doctrine\ORM\Mapping\Column;
10
use Doctrine\ORM\Mapping\Entity;
11
use Doctrine\ORM\Mapping\GeneratedValue;
12
use Doctrine\ORM\Mapping\Id;
13
use Doctrine\ORM\Mapping\JoinColumn;
14
use Doctrine\ORM\Mapping\ManyToOne;
15
use Doctrine\ORM\Mapping\OneToMany;
16
use Doctrine\ORM\Mapping\OneToOne;
17
use Doctrine\ORM\Mapping\OrderBy;
18
use Doctrine\ORM\Mapping\Table;
19
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...
20
use Stu\Orm\Repository\StarSystemRepository;
21
22
#[Table(name: 'stu_systems')]
23
#[Entity(repositoryClass: StarSystemRepository::class)]
24
class StarSystem implements StarSystemInterface
25
{
26
    #[Id]
27
    #[Column(type: 'integer')]
28
    #[GeneratedValue(strategy: 'IDENTITY')]
29
    private int $id;
30
31
    #[Column(type: 'integer')]
32
    private int $type = 0;
0 ignored issues
show
introduced by
The private property $type is not used, and could be removed.
Loading history...
33
34
    #[Column(type: 'string')]
35
    private string $name = '';
36
37
    #[Column(type: 'smallint')]
38
    private int $max_x = 0;
39
40
    #[Column(type: 'smallint')]
41
    private int $max_y = 0;
42
43
    #[Column(type: 'smallint')]
44
    private int $bonus_fields = 0;
45
46
    #[Column(type: 'integer', nullable: true)]
47
    private ?int $database_id = 0;
0 ignored issues
show
introduced by
The private property $database_id is not used, and could be removed.
Loading history...
48
49
    #[Column(type: 'boolean')]
50
    private bool $is_wormhole = false;
51
52
    #[ManyToOne(targetEntity: 'StarSystemType')]
53
    #[JoinColumn(name: 'type', referencedColumnName: 'id', onDelete: 'CASCADE')]
54
    private StarSystemTypeInterface $systemType;
55
56
    #[OneToOne(targetEntity: 'Map', mappedBy: 'starSystem')]
57
    private ?MapInterface $map = null;
58
59
    #[ManyToOne(targetEntity: 'DatabaseEntry')]
60
    #[JoinColumn(name: 'database_id', referencedColumnName: 'id', onDelete: 'CASCADE')]
61
    private ?DatabaseEntryInterface $databaseEntry = null;
62
63
    #[OneToOne(targetEntity: 'Ship', mappedBy: 'influenceArea')]
64
    private ?ShipInterface $base = null;
65
66
    /**
67
     * @var Collection<int, StarSystemMapInterface>
68
     */
69
    #[OneToMany(targetEntity: 'StarSystemMap', mappedBy: 'starSystem')]
70
    #[OrderBy(['sy' => 'ASC', 'sx' => 'ASC'])]
71
    private Collection $fields;
72
73
    /** @var ArrayCollection<int, AstronomicalEntryInterface> */
74
    #[OneToMany(targetEntity: 'AstronomicalEntry', mappedBy: 'starSystem', indexBy: 'user_id', fetch: 'EXTRA_LAZY')]
75
    private Collection $astronomicalEntries;
76
77
    public function __construct()
78
    {
79
        $this->fields = new ArrayCollection();
80
        $this->astronomicalEntries = new ArrayCollection();
81
    }
82
83
    #[Override]
84
    public function getId(): int
85
    {
86
        return $this->id;
87
    }
88
89
    #[Override]
90
    public function getCx(): ?int
91
    {
92
        $map = $this->map;
93
        if ($map !== null) {
94
            return $map->getCx();
95
        }
96
97
        return null;
98
    }
99
100
    #[Override]
101
    public function getCy(): ?int
102
    {
103
        $map = $this->map;
104
        if ($map !== null) {
105
            return $map->getCy();
106
        }
107
108
        return null;
109
    }
110
111
    #[Override]
112
    public function getType(): StarSystemTypeInterface
113
    {
114
        return $this->systemType;
115
    }
116
117
    #[Override]
118
    public function setType(StarSystemTypeInterface $systemType): StarSystemInterface
119
    {
120
        $this->systemType = $systemType;
121
122
        return $this;
123
    }
124
125
    #[Override]
126
    public function getName(): string
127
    {
128
        return $this->name;
129
    }
130
131
    #[Override]
132
    public function setName(string $name): StarSystemInterface
133
    {
134
        $this->name = $name;
135
136
        return $this;
137
    }
138
139
    #[Override]
140
    public function getMaxX(): int
141
    {
142
        return $this->max_x;
143
    }
144
145
    #[Override]
146
    public function setMaxX(int $maxX): StarSystemInterface
147
    {
148
        $this->max_x = $maxX;
149
150
        return $this;
151
    }
152
153
    #[Override]
154
    public function getMaxY(): int
155
    {
156
        return $this->max_y;
157
    }
158
159
    #[Override]
160
    public function setMaxY(int $maxY): StarSystemInterface
161
    {
162
        $this->max_y = $maxY;
163
164
        return $this;
165
    }
166
167
    #[Override]
168
    public function getBonusFieldAmount(): int
169
    {
170
        return $this->bonus_fields;
171
    }
172
173
    #[Override]
174
    public function setBonusFieldAmount(int $bonusFieldAmount): StarSystemInterface
175
    {
176
        $this->bonus_fields = $bonusFieldAmount;
177
178
        return $this;
179
    }
180
181
    #[Override]
182
    public function getSystemType(): StarSystemTypeInterface
183
    {
184
        return $this->systemType;
185
    }
186
187
    #[Override]
188
    public function getDatabaseEntry(): ?DatabaseEntryInterface
189
    {
190
        return $this->databaseEntry;
191
    }
192
193
    #[Override]
194
    public function setDatabaseEntry(?DatabaseEntryInterface $databaseEntry): StarSystemInterface
195
    {
196
        $this->databaseEntry = $databaseEntry;
197
198
        return $this;
199
    }
200
201
    #[Override]
202
    public function getLayer(): ?LayerInterface
203
    {
204
        if ($this->isWormhole()) {
205
            return null;
206
        }
207
208
        return $this->getMap()->getLayer();
209
    }
210
211
    #[Override]
212
    public function getMap(): ?MapInterface
213
    {
214
        return $this->map;
215
    }
216
217
    #[Override]
218
    public function getBase(): ?ShipInterface
219
    {
220
        return $this->base;
221
    }
222
223
    #[Override]
224
    public function getFields(): Collection
225
    {
226
        return $this->fields;
227
    }
228
229
    #[Override]
230
    public function isWormhole(): bool
231
    {
232
        return $this->is_wormhole;
233
    }
234
235
    #[Override]
236
    public function getAstronomicalEntries(): Collection
237
    {
238
        return $this->astronomicalEntries;
239
    }
240
}
241