Passed
Pull Request — master (#1837)
by Nico
24:51
created

StarSystem::setCx()   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\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
    public function __construct()
74
    {
75
        $this->fields = new ArrayCollection();
76
    }
77
78
    #[Override]
79
    public function getId(): int
80
    {
81
        return $this->id;
82
    }
83
84
    #[Override]
85
    public function getCx(): ?int
86
    {
87
        $map = $this->map;
88
        if ($map !== null) {
89
            return $map->getCx();
90
        }
91
92
        return null;
93
    }
94
95
    #[Override]
96
    public function getCy(): ?int
97
    {
98
        $map = $this->map;
99
        if ($map !== null) {
100
            return $map->getCy();
101
        }
102
103
        return null;
104
    }
105
106
    #[Override]
107
    public function getType(): StarSystemTypeInterface
108
    {
109
        return $this->systemType;
110
    }
111
112
    #[Override]
113
    public function setType(StarSystemTypeInterface $systemType): StarSystemInterface
114
    {
115
        $this->systemType = $systemType;
116
117
        return $this;
118
    }
119
120
    #[Override]
121
    public function getName(): string
122
    {
123
        return $this->name;
124
    }
125
126
    #[Override]
127
    public function setName(string $name): StarSystemInterface
128
    {
129
        $this->name = $name;
130
131
        return $this;
132
    }
133
134
    #[Override]
135
    public function getMaxX(): int
136
    {
137
        return $this->max_x;
138
    }
139
140
    #[Override]
141
    public function setMaxX(int $maxX): StarSystemInterface
142
    {
143
        $this->max_x = $maxX;
144
145
        return $this;
146
    }
147
148
    #[Override]
149
    public function getMaxY(): int
150
    {
151
        return $this->max_y;
152
    }
153
154
    #[Override]
155
    public function setMaxY(int $maxY): StarSystemInterface
156
    {
157
        $this->max_y = $maxY;
158
159
        return $this;
160
    }
161
162
    #[Override]
163
    public function getBonusFieldAmount(): int
164
    {
165
        return $this->bonus_fields;
166
    }
167
168
    #[Override]
169
    public function setBonusFieldAmount(int $bonusFieldAmount): StarSystemInterface
170
    {
171
        $this->bonus_fields = $bonusFieldAmount;
172
173
        return $this;
174
    }
175
176
    #[Override]
177
    public function getSystemType(): StarSystemTypeInterface
178
    {
179
        return $this->systemType;
180
    }
181
182
    #[Override]
183
    public function getDatabaseEntry(): ?DatabaseEntryInterface
184
    {
185
        return $this->databaseEntry;
186
    }
187
188
    #[Override]
189
    public function setDatabaseEntry(?DatabaseEntryInterface $databaseEntry): StarSystemInterface
190
    {
191
        $this->databaseEntry = $databaseEntry;
192
193
        return $this;
194
    }
195
196
    #[Override]
197
    public function getLayer(): ?LayerInterface
198
    {
199
        if ($this->isWormhole()) {
200
            return null;
201
        }
202
203
        return $this->getMap()->getLayer();
204
    }
205
206
    #[Override]
207
    public function getMap(): ?MapInterface
208
    {
209
        return $this->map;
210
    }
211
212
    #[Override]
213
    public function getBase(): ?ShipInterface
214
    {
215
        return $this->base;
216
    }
217
218
    #[Override]
219
    public function getFields(): Collection
220
    {
221
        return $this->fields;
222
    }
223
224
    #[Override]
225
    public function isWormhole(): bool
226
    {
227
        return $this->is_wormhole;
228
    }
229
}
230