Passed
Push — master ( dfb12b...5aafb2 )
by Janko
26:27
created

ColonyClass::setDatabaseEntry()   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\OneToMany;
15
use Doctrine\ORM\Mapping\OneToOne;
16
use Doctrine\ORM\Mapping\Table;
17
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...
18
use Stu\Component\Colony\ColonyEnum;
0 ignored issues
show
Bug introduced by
The type Stu\Component\Colony\ColonyEnum 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...
19
use Stu\Component\Colony\ColonyTypeEnum;
0 ignored issues
show
Bug introduced by
The type Stu\Component\Colony\ColonyTypeEnum 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\ColonyClassRepository;
21
22
#[Table(name: 'stu_colonies_classes')]
23
#[Entity(repositoryClass: ColonyClassRepository::class)]
24
class ColonyClass implements ColonyClassInterface
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')]
35
    private int $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
    /**
62
     * @var DatabaseEntryInterface|null
63
     */
64
    #[OneToOne(targetEntity: 'DatabaseEntry')]
65
    #[JoinColumn(name: 'database_id', referencedColumnName: 'id')]
66
    private ?DatabaseEntryInterface $databaseEntry;
67
68
    /**
69
     * @var ArrayCollection<int, ColonyClassDepositInterface>
70
     */
71
    #[OneToMany(targetEntity: 'ColonyClassDeposit', mappedBy: 'colonyClass', indexBy: 'commodity_id')]
72
    private Collection $colonyClassDeposits;
73
74
    public function __construct()
75
    {
76
        $this->colonyClassDeposits = new ArrayCollection();
77
    }
78
79
    #[Override]
80
    public function getId(): int
81
    {
82
        return $this->id;
83
    }
84
85
    #[Override]
86
    public function getName(): string
87
    {
88
        return $this->name;
89
    }
90
91
    #[Override]
92
    public function setName(string $name): ColonyClassInterface
93
    {
94
        $this->name = $name;
95
96
        return $this;
97
    }
98
99
    #[Override]
100
    public function getType(): int
101
    {
102
        return $this->type;
103
    }
104
105
    #[Override]
106
    public function isPlanet(): bool
107
    {
108
        return $this->getType() === ColonyTypeEnum::COLONY_TYPE_PLANET;
109
    }
110
111
    #[Override]
112
    public function isMoon(): bool
113
    {
114
        return $this->getType() === ColonyTypeEnum::COLONY_TYPE_MOON;
115
    }
116
117
    #[Override]
118
    public function isAsteroid(): bool
119
    {
120
        return $this->getType() === ColonyTypeEnum::COLONY_TYPE_ASTEROID;
121
    }
122
123
    #[Override]
124
    public function getDatabaseId(): ?int
125
    {
126
        return $this->database_id;
127
    }
128
129
    #[Override]
130
    public function setDatabaseEntry(?DatabaseEntryInterface $entry): ColonyClassInterface
131
    {
132
        $this->databaseEntry = $entry;
133
134
        return $this;
135
    }
136
137
    #[Override]
138
    public function getColonizeableFields(): array
139
    {
140
        return $this->colonizeable_fields;
141
    }
142
143
    #[Override]
144
    public function setColonizeableFields(array $colonizeableFields): ColonyClassInterface
145
    {
146
        $this->colonizeable_fields = $colonizeableFields;
147
148
        return $this;
149
    }
150
151
    #[Override]
152
    public function getBevGrowthRate(): int
153
    {
154
        return $this->bev_growth_rate;
155
    }
156
157
    #[Override]
158
    public function setBevGrowthRate(int $bevGroethRate): ColonyClassInterface
159
    {
160
        $this->bev_growth_rate = $bevGroethRate;
161
162
        return $this;
163
    }
164
165
    #[Override]
166
    public function getSpecialId(): int
167
    {
168
        return $this->special;
169
    }
170
171
    #[Override]
172
    public function setSpecialId(int $specialId): ColonyClassInterface
173
    {
174
        $this->special = $specialId;
175
176
        return $this;
177
    }
178
179
    #[Override]
180
    public function getAllowStart(): bool
181
    {
182
        return $this->allow_start;
183
    }
184
185
    #[Override]
186
    public function setAllowStart(bool $allowStart): ColonyClassInterface
187
    {
188
        $this->allow_start = $allowStart;
189
190
        return $this;
191
    }
192
193
    #[Override]
194
    public function getColonyClassDeposits(): Collection
195
    {
196
        return $this->colonyClassDeposits;
197
    }
198
199
    #[Override]
200
    public function hasRing(): bool
201
    {
202
        return $this->getSpecialId() == ColonyEnum::COLONY_CLASS_SPECIAL_RING;
203
    }
204
205
    #[Override]
206
    public function getMinRotation(): int
207
    {
208
        return $this->min_rot;
209
    }
210
211
    #[Override]
212
    public function setMinRotation(int $rotation): ColonyClassInterface
213
    {
214
        $this->min_rot = $rotation;
215
216
        return $this;
217
    }
218
219
    #[Override]
220
    public function getMaxRotation(): int
221
    {
222
        return $this->max_rot;
223
    }
224
225
    #[Override]
226
    public function setMaxRotation(int $rotation): ColonyClassInterface
227
    {
228
        $this->max_rot = $rotation;
229
230
        return $this;
231
    }
232
}
233