Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
11.11% |
2 / 18 |
|
20.00% |
2 / 10 |
CRAP | |
0.00% |
0 / 1 |
| Person | |
11.11% |
2 / 18 |
|
20.00% |
2 / 10 |
131.69 | |
0.00% |
0 / 1 |
| __construct | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| getId | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| getFirstname | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| setFirstname | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
2 | |||
| getLastname | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| setLastname | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
2 | |||
| getCastings | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| addCasting | |
0.00% |
0 / 4 |
|
0.00% |
0 / 1 |
6 | |||
| removeCasting | |
0.00% |
0 / 4 |
|
0.00% |
0 / 1 |
12 | |||
| getFullname | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| 1 | <?php |
| 2 | |
| 3 | namespace App\Entity; |
| 4 | |
| 5 | use App\Repository\PersonRepository; |
| 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=PersonRepository::class) |
| 13 | */ |
| 14 | class Person |
| 15 | { |
| 16 | /** |
| 17 | * @ORM\Id |
| 18 | * @ORM\GeneratedValue |
| 19 | * @ORM\Column(type="integer") |
| 20 | * @Groups({"movie_read"}) |
| 21 | */ |
| 22 | private $id; |
| 23 | |
| 24 | /** |
| 25 | * @ORM\Column(type="string", length=255) |
| 26 | * @Groups({"movie_read"}) |
| 27 | */ |
| 28 | private $firstname; |
| 29 | |
| 30 | /** |
| 31 | * @ORM\Column(type="string", length=255) |
| 32 | * @Groups({"movie_read"}) |
| 33 | */ |
| 34 | private $lastname; |
| 35 | |
| 36 | /** |
| 37 | * @ORM\OneToMany(targetEntity=Casting::class, mappedBy="person") |
| 38 | */ |
| 39 | private $castings; |
| 40 | |
| 41 | public function __construct() |
| 42 | { |
| 43 | $this->castings = new ArrayCollection(); |
| 44 | } |
| 45 | |
| 46 | public function getId(): ?int |
| 47 | { |
| 48 | return $this->id; |
| 49 | } |
| 50 | |
| 51 | public function getFirstname(): ?string |
| 52 | { |
| 53 | return $this->firstname; |
| 54 | } |
| 55 | |
| 56 | public function setFirstname(string $firstname): self |
| 57 | { |
| 58 | $this->firstname = $firstname; |
| 59 | |
| 60 | return $this; |
| 61 | } |
| 62 | |
| 63 | public function getLastname(): ?string |
| 64 | { |
| 65 | return $this->lastname; |
| 66 | } |
| 67 | |
| 68 | public function setLastname(string $lastname): self |
| 69 | { |
| 70 | $this->lastname = $lastname; |
| 71 | |
| 72 | return $this; |
| 73 | } |
| 74 | |
| 75 | /** |
| 76 | * @return Collection<int, Casting> |
| 77 | */ |
| 78 | public function getCastings(): Collection |
| 79 | { |
| 80 | return $this->castings; |
| 81 | } |
| 82 | |
| 83 | public function addCasting(Casting $casting): self |
| 84 | { |
| 85 | if (!$this->castings->contains($casting)) { |
| 86 | $this->castings[] = $casting; |
| 87 | $casting->setPerson($this); |
| 88 | } |
| 89 | |
| 90 | return $this; |
| 91 | } |
| 92 | |
| 93 | public function removeCasting(Casting $casting): self |
| 94 | { |
| 95 | if ($this->castings->removeElement($casting)) { |
| 96 | // set the owning side to null (unless already changed) |
| 97 | if ($casting->getPerson() === $this) { |
| 98 | $casting->setPerson(null); |
| 99 | } |
| 100 | } |
| 101 | |
| 102 | return $this; |
| 103 | } |
| 104 | |
| 105 | /** |
| 106 | * Utile pour l'affichage et pour les formulaire |
| 107 | */ |
| 108 | public function getFullname() |
| 109 | { |
| 110 | return $this->getFirstname() . " " . $this->getLastname(); |
| 111 | } |
| 112 | } |