Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
7.69% |
1 / 13 |
|
14.29% |
1 / 7 |
CRAP | |
0.00% |
0 / 1 |
Genre | |
7.69% |
1 / 13 |
|
14.29% |
1 / 7 |
72.71 | |
0.00% |
0 / 1 |
__construct | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
getId | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
getName | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
setName | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
2 | |||
getMovies | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
addMovie | |
0.00% |
0 / 4 |
|
0.00% |
0 / 1 |
6 | |||
removeMovie | |
0.00% |
0 / 3 |
|
0.00% |
0 / 1 |
6 |
1 | <?php |
2 | |
3 | namespace App\Entity; |
4 | |
5 | use App\Repository\GenreRepository; |
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=GenreRepository::class) |
14 | */ |
15 | class Genre |
16 | { |
17 | /** |
18 | * @ORM\Id |
19 | * @ORM\GeneratedValue |
20 | * @ORM\Column(type="integer") |
21 | * |
22 | * @Groups({"genre_browse"}) |
23 | * @Groups({"genre_read"}) |
24 | * @Groups({"movie_read"}) |
25 | */ |
26 | private $id; |
27 | |
28 | /** |
29 | * @ORM\Column(type="string", length=64) |
30 | * |
31 | * @Groups({"genre_browse"}) |
32 | * @Groups({"genre_read"}) |
33 | * @Groups({"movie_read"}) |
34 | * |
35 | * @Assert\NotBlank |
36 | * @Assert\Length(min = 5, max=64) |
37 | */ |
38 | private $name; |
39 | |
40 | /** |
41 | * @ORM\ManyToMany(targetEntity=Movie::class, mappedBy="genres") |
42 | * |
43 | * @Groups({"genre_browse"}) |
44 | * @Groups({"genre_read"}) |
45 | */ |
46 | private $movies; |
47 | |
48 | public function __construct() |
49 | { |
50 | $this->movies = new ArrayCollection(); |
51 | } |
52 | |
53 | public function getId(): ?int |
54 | { |
55 | return $this->id; |
56 | } |
57 | |
58 | public function getName(): ?string |
59 | { |
60 | return $this->name; |
61 | } |
62 | |
63 | public function setName(string $name): self |
64 | { |
65 | $this->name = $name; |
66 | |
67 | return $this; |
68 | } |
69 | |
70 | /** |
71 | * @return Collection<int, Movie> |
72 | */ |
73 | public function getMovies(): Collection |
74 | { |
75 | return $this->movies; |
76 | } |
77 | |
78 | public function addMovie(Movie $movie): self |
79 | { |
80 | if (!$this->movies->contains($movie)) { |
81 | $this->movies[] = $movie; |
82 | $movie->addGenre($this); |
83 | } |
84 | |
85 | return $this; |
86 | } |
87 | |
88 | public function removeMovie(Movie $movie): self |
89 | { |
90 | if ($this->movies->removeElement($movie)) { |
91 | $movie->removeGenre($this); |
92 | } |
93 | |
94 | return $this; |
95 | } |
96 | } |