1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace NekoAPI\Component\Entity; |
4
|
|
|
|
5
|
|
|
/** |
6
|
|
|
* Class Anime |
7
|
|
|
* |
8
|
|
|
* @package NekoAPI\Component\Entity |
9
|
|
|
* @author Aurimas Niekis <[email protected]> |
10
|
|
|
*/ |
11
|
|
|
class Anime extends BaseIdNameEntity |
12
|
|
|
{ |
13
|
|
|
/** |
14
|
|
|
* @var string |
15
|
|
|
*/ |
16
|
|
|
private $slug; |
17
|
|
|
|
18
|
|
|
/** |
19
|
|
|
* @var string |
20
|
|
|
*/ |
21
|
|
|
private $image; |
22
|
|
|
|
23
|
|
|
/** |
24
|
|
|
* @var string |
25
|
|
|
*/ |
26
|
|
|
private $url; |
27
|
|
|
|
28
|
|
|
/** |
29
|
|
|
* @var AlternativeTitles |
30
|
|
|
*/ |
31
|
|
|
private $alternativeTitles; |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* @var Information |
35
|
|
|
*/ |
36
|
|
|
private $information; |
37
|
|
|
|
38
|
|
|
/** |
39
|
|
|
* @var Statistics |
40
|
|
|
*/ |
41
|
|
|
private $statistics; |
42
|
|
|
|
43
|
|
|
/** |
44
|
|
|
* @var Episode[] |
45
|
|
|
*/ |
46
|
|
|
private $episodes; |
47
|
|
|
|
48
|
|
|
/** |
49
|
|
|
* @var string |
50
|
|
|
*/ |
51
|
|
|
private $synopsis; |
52
|
|
|
|
53
|
|
|
/** |
54
|
|
|
* @var string |
55
|
|
|
*/ |
56
|
|
|
private $background; |
57
|
|
|
|
58
|
2 |
|
public function __construct(int $id, string $slug, string $name) |
59
|
|
|
{ |
60
|
2 |
|
parent::__construct($id, $name); |
61
|
|
|
|
62
|
2 |
|
$this->slug = $slug; |
63
|
2 |
|
$this->episodes = []; |
64
|
2 |
|
} |
65
|
|
|
|
66
|
|
|
/** |
67
|
|
|
* @return string |
68
|
|
|
*/ |
69
|
2 |
|
public function getSlug(): ?string |
70
|
|
|
{ |
71
|
2 |
|
return $this->slug; |
72
|
|
|
} |
73
|
|
|
|
74
|
|
|
/** |
75
|
|
|
* @param string $slug |
76
|
|
|
* |
77
|
|
|
* @return Anime |
78
|
|
|
*/ |
79
|
1 |
|
public function setSlug(string $slug): Anime |
80
|
|
|
{ |
81
|
1 |
|
$this->slug = $slug; |
82
|
|
|
|
83
|
1 |
|
return $this; |
84
|
|
|
} |
85
|
|
|
|
86
|
|
|
/** |
87
|
|
|
* @return string |
88
|
|
|
*/ |
89
|
2 |
|
public function getImage(): ?string |
90
|
|
|
{ |
91
|
2 |
|
return $this->image; |
92
|
|
|
} |
93
|
|
|
|
94
|
|
|
/** |
95
|
|
|
* @param string $image |
96
|
|
|
* |
97
|
|
|
* @return Anime |
98
|
|
|
*/ |
99
|
2 |
|
public function setImage(string $image): Anime |
100
|
|
|
{ |
101
|
2 |
|
$this->image = $image; |
102
|
|
|
|
103
|
2 |
|
return $this; |
104
|
|
|
} |
105
|
|
|
|
106
|
|
|
/** |
107
|
|
|
* @return string |
108
|
|
|
*/ |
109
|
2 |
|
public function getUrl(): ?string |
110
|
|
|
{ |
111
|
2 |
|
return $this->url; |
112
|
|
|
} |
113
|
|
|
|
114
|
|
|
/** |
115
|
|
|
* @param string $url |
116
|
|
|
* |
117
|
|
|
* @return Anime |
118
|
|
|
*/ |
119
|
2 |
|
public function setUrl(string $url): Anime |
120
|
|
|
{ |
121
|
2 |
|
$this->url = $url; |
122
|
|
|
|
123
|
2 |
|
return $this; |
124
|
|
|
} |
125
|
|
|
|
126
|
|
|
/** |
127
|
|
|
* @return AlternativeTitles |
128
|
|
|
*/ |
129
|
2 |
|
public function getAlternativeTitles(): ?AlternativeTitles |
130
|
|
|
{ |
131
|
2 |
|
return $this->alternativeTitles; |
132
|
|
|
} |
133
|
|
|
|
134
|
|
|
/** |
135
|
|
|
* @param AlternativeTitles $alternativeTitles |
136
|
|
|
* |
137
|
|
|
* @return Anime |
138
|
|
|
*/ |
139
|
2 |
|
public function setAlternativeTitles(AlternativeTitles $alternativeTitles): Anime |
140
|
|
|
{ |
141
|
2 |
|
$this->alternativeTitles = $alternativeTitles; |
142
|
|
|
|
143
|
2 |
|
return $this; |
144
|
|
|
} |
145
|
|
|
|
146
|
|
|
/** |
147
|
|
|
* @return Information |
148
|
|
|
*/ |
149
|
2 |
|
public function getInformation(): ?Information |
150
|
|
|
{ |
151
|
2 |
|
return $this->information; |
152
|
|
|
} |
153
|
|
|
|
154
|
|
|
/** |
155
|
|
|
* @param Information $information |
156
|
|
|
* |
157
|
|
|
* @return Anime |
158
|
|
|
*/ |
159
|
2 |
|
public function setInformation(Information $information): Anime |
160
|
|
|
{ |
161
|
2 |
|
$this->information = $information; |
162
|
|
|
|
163
|
2 |
|
return $this; |
164
|
|
|
} |
165
|
|
|
|
166
|
|
|
/** |
167
|
|
|
* @return Statistics |
168
|
|
|
*/ |
169
|
2 |
|
public function getStatistics(): ?Statistics |
170
|
|
|
{ |
171
|
2 |
|
return $this->statistics; |
172
|
|
|
} |
173
|
|
|
|
174
|
|
|
/** |
175
|
|
|
* @param Statistics $statistics |
176
|
|
|
* |
177
|
|
|
* @return Anime |
178
|
|
|
*/ |
179
|
2 |
|
public function setStatistics(Statistics $statistics): Anime |
180
|
|
|
{ |
181
|
2 |
|
$this->statistics = $statistics; |
182
|
|
|
|
183
|
2 |
|
return $this; |
184
|
|
|
} |
185
|
|
|
|
186
|
|
|
/** |
187
|
|
|
* @return Episode[] |
188
|
|
|
*/ |
189
|
2 |
|
public function getEpisodes(): array |
190
|
|
|
{ |
191
|
2 |
|
return $this->episodes; |
192
|
|
|
} |
193
|
|
|
|
194
|
|
|
/** |
195
|
|
|
* @param Episode[] $episodes |
196
|
|
|
* |
197
|
|
|
* @return Anime |
198
|
|
|
*/ |
199
|
2 |
|
public function setEpisodes(array $episodes): Anime |
200
|
|
|
{ |
201
|
2 |
|
$this->episodes = $episodes; |
202
|
|
|
|
203
|
2 |
|
return $this; |
204
|
|
|
} |
205
|
|
|
|
206
|
|
|
/** |
207
|
|
|
* @param Episode $episode |
208
|
|
|
* |
209
|
|
|
* @return Anime |
210
|
|
|
*/ |
211
|
1 |
|
public function addEpisode(Episode $episode): Anime |
212
|
|
|
{ |
213
|
1 |
|
$this->episodes[] = $episode; |
214
|
|
|
|
215
|
1 |
|
return $this; |
216
|
|
|
} |
217
|
|
|
|
218
|
|
|
/** |
219
|
|
|
* @return string |
220
|
|
|
*/ |
221
|
2 |
|
public function getSynopsis(): ?string |
222
|
|
|
{ |
223
|
2 |
|
return $this->synopsis; |
224
|
|
|
} |
225
|
|
|
|
226
|
|
|
/** |
227
|
|
|
* @param string $synopsis |
228
|
|
|
* |
229
|
|
|
* @return Anime |
230
|
|
|
*/ |
231
|
2 |
|
public function setSynopsis(string $synopsis): Anime |
232
|
|
|
{ |
233
|
2 |
|
$this->synopsis = $synopsis; |
234
|
|
|
|
235
|
2 |
|
return $this; |
236
|
|
|
} |
237
|
|
|
|
238
|
|
|
/** |
239
|
|
|
* @return string |
240
|
|
|
*/ |
241
|
2 |
|
public function getBackground(): ?string |
242
|
|
|
{ |
243
|
2 |
|
return $this->background; |
244
|
|
|
} |
245
|
|
|
|
246
|
|
|
/** |
247
|
|
|
* @param string $background |
248
|
|
|
* |
249
|
|
|
* @return Anime |
250
|
|
|
*/ |
251
|
2 |
|
public function setBackground(string $background): Anime |
252
|
|
|
{ |
253
|
2 |
|
$this->background = $background; |
254
|
|
|
|
255
|
2 |
|
return $this; |
256
|
|
|
} |
257
|
|
|
|
258
|
|
|
/** |
259
|
|
|
* @inheritDoc |
260
|
|
|
*/ |
261
|
1 |
|
public function jsonSerialize(): array |
262
|
|
|
{ |
263
|
|
|
return [ |
264
|
1 |
|
'id' => $this->getId(), |
265
|
1 |
|
'slug' => $this->getSlug(), |
266
|
1 |
|
'name' => $this->getName(), |
267
|
1 |
|
'image' => $this->getImage(), |
268
|
1 |
|
'url' => $this->getUrl(), |
269
|
1 |
|
'alternative_titles' => $this->getAlternativeTitles(), |
270
|
1 |
|
'information' => $this->getInformation(), |
271
|
1 |
|
'statistics' => $this->getStatistics(), |
272
|
1 |
|
'episodes' => $this->getEpisodes(), |
273
|
1 |
|
'synopsis' => $this->getSynopsis(), |
274
|
1 |
|
'background' => $this->getBackground(), |
275
|
|
|
]; |
276
|
|
|
} |
277
|
|
|
} |