Passed
Push — dev ( f800c2...467836 )
by Janko
36:17
created

StarSystem::setName()   A

Complexity

Conditions 1
Paths 1

Size

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