Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
23.64% |
13 / 55 |
|
44.83% |
13 / 29 |
CRAP | |
0.00% |
0 / 1 |
Movie | |
23.64% |
13 / 55 |
|
44.83% |
13 / 29 |
613.12 | |
0.00% |
0 / 1 |
__construct | |
0.00% |
0 / 3 |
|
0.00% |
0 / 1 |
2 | |||
getId | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
getTitle | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
setTitle | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
2 | |||
getDuration | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
setDuration | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
2 | |||
getRating | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
setRating | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
2 | |||
getSummary | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
setSummary | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
2 | |||
getSynopsis | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
setSynopsis | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
2 | |||
getReleaseDate | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
setReleaseDate | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
2 | |||
getCountry | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
setCountry | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
2 | |||
getPoster | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
setPoster | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
2 | |||
getType | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
setType | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
2 | |||
getCastings | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
addCasting | |
0.00% |
0 / 4 |
|
0.00% |
0 / 1 |
6 | |||
removeCasting | |
0.00% |
0 / 4 |
|
0.00% |
0 / 1 |
12 | |||
getGenres | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
addGenre | |
0.00% |
0 / 3 |
|
0.00% |
0 / 1 |
6 | |||
removeGenre | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
2 | |||
getSeasons | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
addSeason | |
0.00% |
0 / 4 |
|
0.00% |
0 / 1 |
6 | |||
removeSeason | |
0.00% |
0 / 4 |
|
0.00% |
0 / 1 |
12 |
1 | <?php |
2 | |
3 | namespace App\Entity; |
4 | |
5 | use App\Repository\MovieRepository; |
6 | use Doctrine\Common\Collections\ArrayCollection; |
7 | use Doctrine\Common\Collections\Collection; |
8 | use Doctrine\ORM\Mapping as ORM; |
9 | use Symfony\Component\Serializer\Annotation\Groups; |
10 | use Symfony\Component\Validator\Constraints as Assert; |
11 | |
12 | /** |
13 | * @ORM\Entity(repositoryClass=MovieRepository::class) |
14 | */ |
15 | class Movie |
16 | { |
17 | /** |
18 | * @ORM\Id |
19 | * @ORM\GeneratedValue |
20 | * @ORM\Column(type="integer") |
21 | * |
22 | * @Groups({"genre_browse", "movie_read"}) |
23 | * @Groups({"movie_browse"}) |
24 | */ |
25 | private $id; |
26 | |
27 | /** |
28 | * @ORM\Column(type="string", length=255) |
29 | * |
30 | * @Groups({"genre_browse"}) |
31 | * @Groups({"movie_read"}) |
32 | * @Groups({"movie_browse"}) |
33 | * |
34 | * @Assert\NotBlank |
35 | * ? https://symfony.com/doc/5.4/reference/constraints/Length.html |
36 | * @Assert\Length( |
37 | * min = 5, |
38 | * max = 255 |
39 | * ) |
40 | */ |
41 | private $title; |
42 | |
43 | /** |
44 | * @ORM\Column(type="integer") |
45 | * @Groups({"movie_read"}) |
46 | * @Groups({"movie_browse"}) |
47 | * |
48 | * @Assert\NotBlank |
49 | */ |
50 | private $duration; |
51 | |
52 | /** |
53 | * @ORM\Column(type="float") |
54 | * @Groups({"movie_read"}) |
55 | * @Groups({"movie_browse"}) |
56 | * |
57 | * @Assert\NotBlank |
58 | */ |
59 | private $rating; |
60 | |
61 | /** |
62 | * @ORM\Column(type="text") |
63 | * @Groups({"movie_browse"}) |
64 | * @Assert\NotBlank |
65 | * @Assert\Length(min = 10) |
66 | */ |
67 | private $summary; |
68 | |
69 | /** |
70 | * @ORM\Column(type="text") |
71 | * @Groups({"movie_read"}) |
72 | * @Assert\NotBlank |
73 | * @Assert\Length(min = 20) |
74 | */ |
75 | private $synopsis; |
76 | |
77 | /** |
78 | * @ORM\Column(type="date") |
79 | * @Groups({"movie_read"}) |
80 | * @Assert\NotBlank |
81 | */ |
82 | private $releaseDate; |
83 | |
84 | /** |
85 | * @ORM\Column(type="string", length=64) |
86 | * @Groups({"movie_read"}) |
87 | * |
88 | * @Assert\NotBlank |
89 | */ |
90 | private $country; |
91 | |
92 | /** |
93 | * @ORM\Column(type="string", length=255) |
94 | * @Groups({"movie_read"}) |
95 | * @Groups({"movie_browse"}) |
96 | * |
97 | * @Assert\NotBlank |
98 | */ |
99 | private $poster; |
100 | |
101 | /** |
102 | * @ORM\ManyToOne(targetEntity=Type::class, inversedBy="movies") |
103 | * @ORM\JoinColumn(nullable=false) |
104 | * |
105 | * @Groups({"movie_read"}) |
106 | * @Groups({"movie_browse"}) |
107 | * |
108 | * @Assert\NotBlank |
109 | */ |
110 | private $type; |
111 | |
112 | /** |
113 | * @ORM\OneToMany(targetEntity=Casting::class, mappedBy="movie") |
114 | * @Groups({"movie_read"}) |
115 | */ |
116 | private $castings; |
117 | |
118 | /** |
119 | * @ORM\ManyToMany(targetEntity=Genre::class, inversedBy="movies") |
120 | * @Groups({"movie_read"}) |
121 | */ |
122 | private $genres; |
123 | |
124 | /** |
125 | * @ORM\OneToMany(targetEntity=Season::class, mappedBy="movie") |
126 | * @Groups({"movie_read"}) |
127 | */ |
128 | private $seasons; |
129 | |
130 | public function __construct() |
131 | { |
132 | $this->castings = new ArrayCollection(); |
133 | $this->genres = new ArrayCollection(); |
134 | $this->seasons = new ArrayCollection(); |
135 | } |
136 | |
137 | public function getId(): ?int |
138 | { |
139 | return $this->id; |
140 | } |
141 | |
142 | public function getTitle(): ?string |
143 | { |
144 | return $this->title; |
145 | } |
146 | |
147 | public function setTitle(string $title): self |
148 | { |
149 | $this->title = $title; |
150 | |
151 | return $this; |
152 | } |
153 | |
154 | public function getDuration(): ?int |
155 | { |
156 | return $this->duration; |
157 | } |
158 | |
159 | public function setDuration(int $duration): self |
160 | { |
161 | $this->duration = $duration; |
162 | |
163 | return $this; |
164 | } |
165 | |
166 | public function getRating(): ?float |
167 | { |
168 | return $this->rating; |
169 | } |
170 | |
171 | public function setRating(float $rating): self |
172 | { |
173 | $this->rating = $rating; |
174 | |
175 | return $this; |
176 | } |
177 | |
178 | public function getSummary(): ?string |
179 | { |
180 | return $this->summary; |
181 | } |
182 | |
183 | public function setSummary(string $summary): self |
184 | { |
185 | $this->summary = $summary; |
186 | |
187 | return $this; |
188 | } |
189 | |
190 | public function getSynopsis(): ?string |
191 | { |
192 | return $this->synopsis; |
193 | } |
194 | |
195 | public function setSynopsis(string $synopsis): self |
196 | { |
197 | $this->synopsis = $synopsis; |
198 | |
199 | return $this; |
200 | } |
201 | |
202 | public function getReleaseDate(): ?\DateTimeInterface |
203 | { |
204 | return $this->releaseDate; |
205 | } |
206 | |
207 | public function setReleaseDate(\DateTimeInterface $releaseDate): self |
208 | { |
209 | $this->releaseDate = $releaseDate; |
210 | |
211 | return $this; |
212 | } |
213 | |
214 | public function getCountry(): ?string |
215 | { |
216 | return $this->country; |
217 | } |
218 | |
219 | public function setCountry(string $country): self |
220 | { |
221 | $this->country = $country; |
222 | |
223 | return $this; |
224 | } |
225 | |
226 | public function getPoster(): ?string |
227 | { |
228 | return $this->poster; |
229 | } |
230 | |
231 | public function setPoster(string $poster): self |
232 | { |
233 | $this->poster = $poster; |
234 | |
235 | return $this; |
236 | } |
237 | |
238 | public function getType(): ?Type |
239 | { |
240 | return $this->type; |
241 | } |
242 | |
243 | public function setType(?Type $type): self |
244 | { |
245 | $this->type = $type; |
246 | |
247 | return $this; |
248 | } |
249 | |
250 | /** |
251 | * @return Collection<int, Casting> |
252 | */ |
253 | public function getCastings(): Collection |
254 | { |
255 | return $this->castings; |
256 | } |
257 | |
258 | public function addCasting(Casting $casting): self |
259 | { |
260 | if (!$this->castings->contains($casting)) { |
261 | $this->castings[] = $casting; |
262 | $casting->setMovie($this); |
263 | } |
264 | |
265 | return $this; |
266 | } |
267 | |
268 | public function removeCasting(Casting $casting): self |
269 | { |
270 | if ($this->castings->removeElement($casting)) { |
271 | // set the owning side to null (unless already changed) |
272 | if ($casting->getMovie() === $this) { |
273 | $casting->setMovie(null); |
274 | } |
275 | } |
276 | |
277 | return $this; |
278 | } |
279 | |
280 | /** |
281 | * @return Collection<int, Genre> |
282 | */ |
283 | public function getGenres(): Collection |
284 | { |
285 | return $this->genres; |
286 | } |
287 | |
288 | public function addGenre(Genre $genre): self |
289 | { |
290 | if (!$this->genres->contains($genre)) { |
291 | $this->genres[] = $genre; |
292 | } |
293 | |
294 | return $this; |
295 | } |
296 | |
297 | public function removeGenre(Genre $genre): self |
298 | { |
299 | $this->genres->removeElement($genre); |
300 | |
301 | return $this; |
302 | } |
303 | |
304 | /** |
305 | * @return Collection<int, Season> |
306 | */ |
307 | public function getSeasons(): Collection |
308 | { |
309 | return $this->seasons; |
310 | } |
311 | |
312 | public function addSeason(Season $season): self |
313 | { |
314 | if (!$this->seasons->contains($season)) { |
315 | $this->seasons[] = $season; |
316 | $season->setMovie($this); |
317 | } |
318 | |
319 | return $this; |
320 | } |
321 | |
322 | public function removeSeason(Season $season): self |
323 | { |
324 | if ($this->seasons->removeElement($season)) { |
325 | // set the owning side to null (unless already changed) |
326 | if ($season->getMovie() === $this) { |
327 | $season->setMovie(null); |
328 | } |
329 | } |
330 | |
331 | return $this; |
332 | } |
333 | } |