Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
7.14% |
1 / 14 |
|
14.29% |
1 / 7 |
CRAP | |
0.00% |
0 / 1 |
Type | |
7.14% |
1 / 14 |
|
14.29% |
1 / 7 |
90.07 | |
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 / 4 |
|
0.00% |
0 / 1 |
12 |
1 | <?php |
2 | |
3 | namespace App\Entity; |
4 | |
5 | use App\Repository\TypeRepository; |
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 | |
11 | /** |
12 | * @ORM\Entity(repositoryClass=TypeRepository::class) |
13 | */ |
14 | class Type |
15 | { |
16 | /** |
17 | * @ORM\Id |
18 | * @ORM\GeneratedValue |
19 | * @ORM\Column(type="integer") |
20 | * |
21 | * @Groups({"movie_read"}) |
22 | * @Groups({"movie_browse"}) |
23 | */ |
24 | private $id; |
25 | |
26 | /** |
27 | * @ORM\Column(type="string", length=10) |
28 | * |
29 | * @Groups({"movie_read"}) |
30 | * @Groups({"movie_browse"}) |
31 | */ |
32 | private $name; |
33 | |
34 | /** |
35 | * @ORM\OneToMany(targetEntity=Movie::class, mappedBy="type") |
36 | */ |
37 | private $movies; |
38 | |
39 | public function __construct() |
40 | { |
41 | $this->movies = new ArrayCollection(); |
42 | } |
43 | |
44 | public function getId(): ?int |
45 | { |
46 | return $this->id; |
47 | } |
48 | |
49 | public function getName(): ?string |
50 | { |
51 | return $this->name; |
52 | } |
53 | |
54 | public function setName(string $name): self |
55 | { |
56 | $this->name = $name; |
57 | |
58 | return $this; |
59 | } |
60 | |
61 | /** |
62 | * @return Collection<int, Movie> |
63 | */ |
64 | public function getMovies(): Collection |
65 | { |
66 | return $this->movies; |
67 | } |
68 | |
69 | public function addMovie(Movie $movie): self |
70 | { |
71 | if (!$this->movies->contains($movie)) { |
72 | $this->movies[] = $movie; |
73 | $movie->setType($this); |
74 | } |
75 | |
76 | return $this; |
77 | } |
78 | |
79 | public function removeMovie(Movie $movie): self |
80 | { |
81 | if ($this->movies->removeElement($movie)) { |
82 | // set the owning side to null (unless already changed) |
83 | if ($movie->getType() === $this) { |
84 | $movie->setType(null); |
85 | } |
86 | } |
87 | |
88 | return $this; |
89 | } |
90 | } |