Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
85.71% |
12 / 14 |
|
83.33% |
10 / 12 |
CRAP | |
0.00% |
0 / 1 |
| Task | |
85.71% |
12 / 14 |
|
83.33% |
10 / 12 |
12.42 | |
0.00% |
0 / 1 |
| __construct | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
| getId | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| getCreatedAt | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| setCreatedAt | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| getTitle | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| setTitle | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| getContent | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| setContent | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| isDone | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| toggle | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| getAuthor | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| setAuthor | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | |
| 3 | namespace App\Entity; |
| 4 | |
| 5 | use Datetime; |
| 6 | use Doctrine\ORM\Mapping as ORM; |
| 7 | use App\Repository\TaskRepository; |
| 8 | use Symfony\Component\Security\Core\User\UserInterface; |
| 9 | use Symfony\Component\Validator\Constraints as Assert; |
| 10 | |
| 11 | #[ORM\Entity(repositoryClass:TaskRepository::class)] |
| 12 | #[ORM\Table] |
| 13 | class Task |
| 14 | { |
| 15 | #[ORM\Column(type:"integer")] |
| 16 | #[ORM\Id] |
| 17 | #[ORM\GeneratedValue(strategy:"AUTO")] |
| 18 | private ?int $id = null; |
| 19 | |
| 20 | #[ORM\Column(type:"datetime")] |
| 21 | private DateTime $createdAt; |
| 22 | |
| 23 | #[ORM\Column(type:"string")] |
| 24 | #[Assert\NotBlank(message:"Vous devez saisir un titre.")] |
| 25 | private string $title; |
| 26 | |
| 27 | #[ORM\Column(type:"text")] |
| 28 | #[Assert\NotBlank(message:"Vous devez saisir du contenu.")] |
| 29 | private string $content; |
| 30 | |
| 31 | #[ORM\Column(type:"boolean")] |
| 32 | private bool $isDone; |
| 33 | |
| 34 | #[ORM\ManyToOne(targetEntity:User::class, inversedBy:"tasks")] |
| 35 | #[ORM\JoinColumn(name:"user_id",referencedColumnName:"id", nullable:true, onDelete:"CASCADE")] |
| 36 | private ?User $author; |
| 37 | |
| 38 | public function __construct() |
| 39 | { |
| 40 | $this->createdAt = new Datetime(); |
| 41 | $this->isDone = false; |
| 42 | } |
| 43 | |
| 44 | public function getId(): ?int |
| 45 | { |
| 46 | return $this->id; |
| 47 | } |
| 48 | |
| 49 | public function getCreatedAt(): Datetime |
| 50 | { |
| 51 | return $this->createdAt; |
| 52 | } |
| 53 | |
| 54 | public function setCreatedAt($createdAt) |
| 55 | { |
| 56 | $this->createdAt = $createdAt; |
| 57 | } |
| 58 | |
| 59 | public function getTitle(): string |
| 60 | { |
| 61 | return $this->title; |
| 62 | } |
| 63 | |
| 64 | public function setTitle($title) |
| 65 | { |
| 66 | $this->title = $title; |
| 67 | } |
| 68 | |
| 69 | public function getContent(): string |
| 70 | { |
| 71 | return $this->content; |
| 72 | } |
| 73 | |
| 74 | public function setContent($content) |
| 75 | { |
| 76 | $this->content = $content; |
| 77 | } |
| 78 | |
| 79 | public function isDone(): bool |
| 80 | { |
| 81 | return $this->isDone; |
| 82 | } |
| 83 | |
| 84 | public function toggle($flag) |
| 85 | { |
| 86 | $this->isDone = $flag; |
| 87 | } |
| 88 | |
| 89 | public function getAuthor(): ?User |
| 90 | { |
| 91 | return $this->author; |
| 92 | } |
| 93 | |
| 94 | public function setAuthor(User|UserInterface $author): self |
| 95 | { |
| 96 | $this->author = $author; |
| 97 | |
| 98 | return $this; |
| 99 | } |
| 100 | } |