|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace VideoGamesRecords\IgdbBundle\Entity; |
|
6
|
|
|
|
|
7
|
|
|
use Doctrine\Common\Collections\ArrayCollection; |
|
8
|
|
|
use Doctrine\Common\Collections\Collection; |
|
9
|
|
|
use Doctrine\ORM\Mapping as ORM; |
|
10
|
|
|
|
|
11
|
|
|
#[ORM\Entity] |
|
12
|
|
|
#[ORM\Table(name: 'igdb_game')] |
|
13
|
|
|
class Game |
|
14
|
|
|
{ |
|
15
|
|
|
#[ORM\Id] |
|
16
|
|
|
#[ORM\Column(type: 'integer')] |
|
17
|
|
|
private int $id; |
|
18
|
|
|
|
|
19
|
|
|
#[ORM\Column(type: 'string', length: 255)] |
|
20
|
|
|
private string $name; |
|
21
|
|
|
|
|
22
|
|
|
#[ORM\Column(type: 'string', length: 255, nullable: true)] |
|
23
|
|
|
private ?string $slug = null; |
|
24
|
|
|
|
|
25
|
|
|
#[ORM\Column(type: 'text', nullable: true)] |
|
26
|
|
|
private ?string $storyline = null; |
|
27
|
|
|
|
|
28
|
|
|
#[ORM\Column(type: 'text', nullable: true)] |
|
29
|
|
|
private ?string $summary = null; |
|
30
|
|
|
|
|
31
|
|
|
#[ORM\Column(type: 'string', length: 500, nullable: true)] |
|
32
|
|
|
private ?string $url = null; |
|
33
|
|
|
|
|
34
|
|
|
#[ORM\Column(type: 'string', length: 255, nullable: true)] |
|
35
|
|
|
private ?string $checksum = null; |
|
36
|
|
|
|
|
37
|
|
|
#[ORM\Column(type: 'integer', nullable: true)] |
|
38
|
|
|
private ?int $firstReleaseDate = null; |
|
39
|
|
|
|
|
40
|
|
|
#[ORM\ManyToOne(targetEntity: Game::class)] |
|
41
|
|
|
#[ORM\JoinColumn(name: 'version_parent_id', referencedColumnName: 'id', nullable: true)] |
|
42
|
|
|
private ?Game $versionParent = null; |
|
43
|
|
|
|
|
44
|
|
|
/** |
|
45
|
|
|
* @var Collection<int, Genre> |
|
46
|
|
|
*/ |
|
47
|
|
|
#[ORM\ManyToMany(targetEntity: Genre::class)] |
|
48
|
|
|
#[ORM\JoinTable( |
|
49
|
|
|
name: 'igdb_game_genre', |
|
50
|
|
|
joinColumns: [new ORM\JoinColumn(name: 'game_id', referencedColumnName: 'id')], |
|
51
|
|
|
inverseJoinColumns: [new ORM\JoinColumn(name: 'genre_id', referencedColumnName: 'id')] |
|
52
|
|
|
)] |
|
53
|
|
|
private Collection $genres; |
|
54
|
|
|
|
|
55
|
|
|
/** |
|
56
|
|
|
* @var Collection<int, Platform> |
|
57
|
|
|
*/ |
|
58
|
|
|
#[ORM\ManyToMany(targetEntity: Platform::class)] |
|
59
|
|
|
#[ORM\JoinTable( |
|
60
|
|
|
name: 'igdb_game_platform', |
|
61
|
|
|
joinColumns: [new ORM\JoinColumn(name: 'game_id', referencedColumnName: 'id')], |
|
62
|
|
|
inverseJoinColumns: [new ORM\JoinColumn(name: 'platform_id', referencedColumnName: 'id')] |
|
63
|
|
|
)] |
|
64
|
|
|
private Collection $platforms; |
|
65
|
|
|
|
|
66
|
|
|
#[ORM\Column(type: 'datetime_immutable')] |
|
67
|
|
|
private \DateTimeImmutable $createdAt; |
|
68
|
|
|
|
|
69
|
|
|
#[ORM\Column(type: 'datetime_immutable')] |
|
70
|
|
|
private \DateTimeImmutable $updatedAt; |
|
71
|
|
|
|
|
72
|
|
|
public function __construct() |
|
73
|
|
|
{ |
|
74
|
|
|
$this->genres = new ArrayCollection(); |
|
75
|
|
|
$this->platforms = new ArrayCollection(); |
|
76
|
|
|
$this->createdAt = new \DateTimeImmutable(); |
|
77
|
|
|
$this->updatedAt = new \DateTimeImmutable(); |
|
78
|
|
|
} |
|
79
|
|
|
|
|
80
|
|
|
public function getId(): int |
|
81
|
|
|
{ |
|
82
|
|
|
return $this->id; |
|
83
|
|
|
} |
|
84
|
|
|
|
|
85
|
|
|
public function setId(int $id): void |
|
86
|
|
|
{ |
|
87
|
|
|
$this->id = $id; |
|
88
|
|
|
} |
|
89
|
|
|
|
|
90
|
|
|
public function getName(): string |
|
91
|
|
|
{ |
|
92
|
|
|
return $this->name; |
|
93
|
|
|
} |
|
94
|
|
|
|
|
95
|
|
|
public function setName(string $name): void |
|
96
|
|
|
{ |
|
97
|
|
|
$this->name = $name; |
|
98
|
|
|
} |
|
99
|
|
|
|
|
100
|
|
|
public function getSlug(): ?string |
|
101
|
|
|
{ |
|
102
|
|
|
return $this->slug; |
|
103
|
|
|
} |
|
104
|
|
|
|
|
105
|
|
|
public function setSlug(?string $slug): void |
|
106
|
|
|
{ |
|
107
|
|
|
$this->slug = $slug; |
|
108
|
|
|
} |
|
109
|
|
|
|
|
110
|
|
|
public function getStoryline(): ?string |
|
111
|
|
|
{ |
|
112
|
|
|
return $this->storyline; |
|
113
|
|
|
} |
|
114
|
|
|
|
|
115
|
|
|
public function setStoryline(?string $storyline): void |
|
116
|
|
|
{ |
|
117
|
|
|
$this->storyline = $storyline; |
|
118
|
|
|
} |
|
119
|
|
|
|
|
120
|
|
|
public function getSummary(): ?string |
|
121
|
|
|
{ |
|
122
|
|
|
return $this->summary; |
|
123
|
|
|
} |
|
124
|
|
|
|
|
125
|
|
|
public function setSummary(?string $summary): void |
|
126
|
|
|
{ |
|
127
|
|
|
$this->summary = $summary; |
|
128
|
|
|
} |
|
129
|
|
|
|
|
130
|
|
|
public function getUrl(): ?string |
|
131
|
|
|
{ |
|
132
|
|
|
return $this->url; |
|
133
|
|
|
} |
|
134
|
|
|
|
|
135
|
|
|
public function setUrl(?string $url): void |
|
136
|
|
|
{ |
|
137
|
|
|
$this->url = $url; |
|
138
|
|
|
} |
|
139
|
|
|
|
|
140
|
|
|
public function getChecksum(): ?string |
|
141
|
|
|
{ |
|
142
|
|
|
return $this->checksum; |
|
143
|
|
|
} |
|
144
|
|
|
|
|
145
|
|
|
public function setChecksum(?string $checksum): void |
|
146
|
|
|
{ |
|
147
|
|
|
$this->checksum = $checksum; |
|
148
|
|
|
} |
|
149
|
|
|
|
|
150
|
|
|
public function getFirstReleaseDate(): ?int |
|
151
|
|
|
{ |
|
152
|
|
|
return $this->firstReleaseDate; |
|
153
|
|
|
} |
|
154
|
|
|
|
|
155
|
|
|
public function setFirstReleaseDate(?int $firstReleaseDate): void |
|
156
|
|
|
{ |
|
157
|
|
|
$this->firstReleaseDate = $firstReleaseDate; |
|
158
|
|
|
} |
|
159
|
|
|
|
|
160
|
|
|
public function getFirstReleaseDateAsDateTime(): ?\DateTimeImmutable |
|
161
|
|
|
{ |
|
162
|
|
|
return $this->firstReleaseDate ? new \DateTimeImmutable('@' . $this->firstReleaseDate) : null; |
|
163
|
|
|
} |
|
164
|
|
|
|
|
165
|
|
|
public function getVersionParent(): ?Game |
|
166
|
|
|
{ |
|
167
|
|
|
return $this->versionParent; |
|
168
|
|
|
} |
|
169
|
|
|
|
|
170
|
|
|
public function setVersionParent(?Game $versionParent): void |
|
171
|
|
|
{ |
|
172
|
|
|
$this->versionParent = $versionParent; |
|
173
|
|
|
} |
|
174
|
|
|
|
|
175
|
|
|
public function getGenres(): Collection |
|
176
|
|
|
{ |
|
177
|
|
|
return $this->genres; |
|
178
|
|
|
} |
|
179
|
|
|
|
|
180
|
|
|
public function addGenre(Genre $genre): self |
|
181
|
|
|
{ |
|
182
|
|
|
if (!$this->genres->contains($genre)) { |
|
183
|
|
|
$this->genres->add($genre); |
|
184
|
|
|
} |
|
185
|
|
|
|
|
186
|
|
|
return $this; |
|
187
|
|
|
} |
|
188
|
|
|
|
|
189
|
|
|
public function removeGenre(Genre $genre): self |
|
190
|
|
|
{ |
|
191
|
|
|
$this->genres->removeElement($genre); |
|
192
|
|
|
|
|
193
|
|
|
return $this; |
|
194
|
|
|
} |
|
195
|
|
|
|
|
196
|
|
|
public function getPlatforms(): Collection |
|
197
|
|
|
{ |
|
198
|
|
|
return $this->platforms; |
|
199
|
|
|
} |
|
200
|
|
|
|
|
201
|
|
|
public function addPlatform(Platform $platform): self |
|
202
|
|
|
{ |
|
203
|
|
|
if (!$this->platforms->contains($platform)) { |
|
204
|
|
|
$this->platforms->add($platform); |
|
205
|
|
|
} |
|
206
|
|
|
|
|
207
|
|
|
return $this; |
|
208
|
|
|
} |
|
209
|
|
|
|
|
210
|
|
|
public function removePlatform(Platform $platform): self |
|
211
|
|
|
{ |
|
212
|
|
|
$this->platforms->removeElement($platform); |
|
213
|
|
|
|
|
214
|
|
|
return $this; |
|
215
|
|
|
} |
|
216
|
|
|
|
|
217
|
|
|
public function getCreatedAt(): \DateTimeImmutable |
|
218
|
|
|
{ |
|
219
|
|
|
return $this->createdAt; |
|
220
|
|
|
} |
|
221
|
|
|
|
|
222
|
|
|
public function setCreatedAt(\DateTimeImmutable $createdAt): void |
|
223
|
|
|
{ |
|
224
|
|
|
$this->createdAt = $createdAt; |
|
225
|
|
|
} |
|
226
|
|
|
|
|
227
|
|
|
public function getUpdatedAt(): \DateTimeImmutable |
|
228
|
|
|
{ |
|
229
|
|
|
return $this->updatedAt; |
|
230
|
|
|
} |
|
231
|
|
|
|
|
232
|
|
|
public function setUpdatedAt(\DateTimeImmutable $updatedAt): void |
|
233
|
|
|
{ |
|
234
|
|
|
$this->updatedAt = $updatedAt; |
|
235
|
|
|
} |
|
236
|
|
|
|
|
237
|
|
|
public function __toString(): string |
|
238
|
|
|
{ |
|
239
|
|
|
return $this->name; |
|
240
|
|
|
} |
|
241
|
|
|
} |
|
242
|
|
|
|