Passed
Push — master ( 5a11dc...578008 )
by Janko
08:39
created

ColonyClass::getMaxRotation()   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
c 0
b 0
f 0
nc 1
nop 0
dl 0
loc 3
ccs 0
cts 2
cp 0
crap 2
rs 10
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\OneToMany;
15
use Doctrine\ORM\Mapping\OneToOne;
16
use Doctrine\ORM\Mapping\Table;
17
use Stu\Component\Colony\ColonyTypeEnum;
18
use Stu\Orm\Repository\ColonyClassRepository;
19
20
#[Table(name: 'stu_colonies_classes')]
21
#[Entity(repositoryClass: ColonyClassRepository::class)]
22
class ColonyClass
23
{
24
    private const int COLONY_CLASS_SPECIAL_RING = 1;
0 ignored issues
show
Bug introduced by
A parse error occurred: Syntax error, unexpected T_STRING, expecting '=' on line 24 at column 22
Loading history...
25
26
    #[Id]
27
    #[Column(type: 'integer')]
28
    #[GeneratedValue(strategy: 'IDENTITY')]
29
    private int $id;
30
31
    #[Column(type: 'string')]
32
    private string $name = '';
33
34
    #[Column(type: 'integer', enumType: ColonyTypeEnum::class)]
35
    private ColonyTypeEnum $type;
36
37
    #[Column(type: 'integer', nullable: true)]
38
    private ?int $database_id = null;
39
40
    /**
41
     * @var array<int>
42
     */
43
    #[Column(type: 'json')]
44
    private array $colonizeable_fields = [];
45
46
    #[Column(type: 'smallint')]
47
    private int $bev_growth_rate = 0;
48
49
    #[Column(type: 'smallint')]
50
    private int $special = 0;
51
52
    #[Column(type: 'boolean')]
53
    private bool $allow_start = false;
54
55
    #[Column(type: 'integer')]
56
    private int $min_rot = 1;
57
58
    #[Column(type: 'integer')]
59
    private int $max_rot = 1;
60
61
    #[OneToOne(targetEntity: DatabaseEntry::class)]
62
    #[JoinColumn(name: 'database_id', referencedColumnName: 'id')]
63
    private ?DatabaseEntry $databaseEntry;
64
65
    /**
66
     * @var ArrayCollection<int, ColonyClassDeposit>
67
     */
68
    #[OneToMany(targetEntity: ColonyClassDeposit::class, mappedBy: 'colonyClass', indexBy: 'commodity_id')]
69
    private Collection $colonyClassDeposits;
70
71
    /**
72
     * @var ArrayCollection<int, ColonyClassRestriction>
73
     */
74
    #[OneToMany(mappedBy: 'colonyClass', targetEntity: ColonyClassRestriction::class)]
75
    private Collection $restrictions;
76
77
78
    public function __construct()
79
    {
80
        $this->colonyClassDeposits = new ArrayCollection();
81
        $this->restrictions = new ArrayCollection();
82
    }
83
84 23
    public function getId(): int
85
    {
86 23
        return $this->id;
87
    }
88
89
    public function getName(): string
90
    {
91
        return $this->name;
92
    }
93
94
    public function setName(string $name): ColonyClass
95
    {
96
        $this->name = $name;
97
98
        return $this;
99
    }
100
101 4
    public function getType(): ColonyTypeEnum
102
    {
103 4
        return $this->type;
104
    }
105
106 4
    public function isPlanet(): bool
107
    {
108 4
        return $this->getType() === ColonyTypeEnum::PLANET;
109
    }
110
111
    public function isMoon(): bool
112
    {
113
        return $this->getType() === ColonyTypeEnum::MOON;
114
    }
115
116
    public function isAsteroid(): bool
117
    {
118
        return $this->getType() === ColonyTypeEnum::ASTEROID;
119
    }
120
121 1
    public function getDatabaseId(): ?int
122
    {
123 1
        return $this->database_id;
124
    }
125
126
    public function setDatabaseEntry(?DatabaseEntry $entry): ColonyClass
127
    {
128
        $this->databaseEntry = $entry;
129
130
        return $this;
131
    }
132
133
    /**
134
     * @return array<int>
135
     */
136
    public function getColonizeableFields(): array
137
    {
138
        return $this->colonizeable_fields;
139
    }
140
141
    /**
142
     * @param array<int> $colonizeableFields
143
     */
144
    public function setColonizeableFields(array $colonizeableFields): ColonyClass
145
    {
146
        $this->colonizeable_fields = $colonizeableFields;
147
148
        return $this;
149
    }
150
151 5
    public function getBevGrowthRate(): int
152
    {
153 5
        return $this->bev_growth_rate;
154
    }
155
156
    public function setBevGrowthRate(int $bevGroethRate): ColonyClass
157
    {
158
        $this->bev_growth_rate = $bevGroethRate;
159
160
        return $this;
161
    }
162
163 2
    public function getSpecialId(): int
164
    {
165 2
        return $this->special;
166
    }
167
168
    public function setSpecialId(int $specialId): ColonyClass
169
    {
170
        $this->special = $specialId;
171
172
        return $this;
173
    }
174
175
    public function getAllowStart(): bool
176
    {
177
        return $this->allow_start;
178
    }
179
180
    public function setAllowStart(bool $allowStart): ColonyClass
181
    {
182
        $this->allow_start = $allowStart;
183
184
        return $this;
185
    }
186
187
    /**
188
     * @return Collection<int, ColonyClassDeposit>
189
     */
190
    public function getColonyClassDeposits(): Collection
191
    {
192
        return $this->colonyClassDeposits;
193
    }
194
195 2
    public function hasRing(): bool
196
    {
197 2
        return $this->getSpecialId() == self::COLONY_CLASS_SPECIAL_RING;
198
    }
199
200
    public function getMinRotation(): int
201
    {
202
        return $this->min_rot;
203
    }
204
205
    public function setMinRotation(int $rotation): ColonyClass
206
    {
207
        $this->min_rot = $rotation;
208
209
        return $this;
210
    }
211
212
    public function getMaxRotation(): int
213
    {
214
        return $this->max_rot;
215
    }
216
217
    public function setMaxRotation(int $rotation): ColonyClass
218
    {
219
        $this->max_rot = $rotation;
220
221
        return $this;
222
    }
223
224
    /**
225
     * @return Collection<int, ColonyClassRestriction>
226
     */
227
    public function getRestrictions(): Collection
228
    {
229
        return $this->restrictions;
230
    }
231
}
232