Passed
Push — master ( 9a5248...3e435d )
by Nico
58:39 queued 28:58
created

StarSystem::getName()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

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