Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
96.30% covered (success)
96.30%
26 / 27
93.33% covered (success)
93.33%
14 / 15
CRAP
0.00% covered (danger)
0.00%
0 / 1
Pages
96.30% covered (success)
96.30%
26 / 27
93.33% covered (success)
93.33%
14 / 15
15
0.00% covered (danger)
0.00%
0 / 1
 getId
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getName
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 setName
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
1 / 1
1
 getContent
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 setContent
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
1 / 1
1
 getCreatedAt
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 setCreatedAt
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
1 / 1
1
 getModifiedAt
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 setModifiedAt
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
1 / 1
1
 getOwner
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 setOwner
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
1 / 1
1
 getSlug
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 setSlug
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
1 / 1
1
 onPrePersist
100.00% covered (success)
100.00%
4 / 4
100.00% covered (success)
100.00%
1 / 1
1
 onPreUpdate
100.00% covered (success)
100.00%
4 / 4
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2
3namespace App\Entity;
4
5use App\Repository\PagesRepository;
6use DateTimeImmutable;
7use Doctrine\ORM\Mapping as ORM;
8use Sunrise\Slugger\Slugger;
9
10#[ORM\Entity(repositoryClass: PagesRepository::class), ORM\HasLifecycleCallbacks]
11
12class Pages
13{
14    #[ORM\Id]
15    #[ORM\GeneratedValue]
16    #[ORM\Column(type: 'integer')]
17    private ?int $id;
18
19    #[ORM\Column(type: 'string', length: 255)]
20    private string $name;
21
22    #[ORM\Column(type: 'text')]
23    private string $content;
24
25    #[ORM\Column(type: 'datetime_immutable')]
26    private ?DateTimeImmutable $createdAt;
27
28    #[ORM\Column(type: 'datetime_immutable', nullable: true)]
29    private ?DateTimeImmutable $modifiedAt;
30
31    #[ORM\ManyToOne(targetEntity: User::class, inversedBy: 'pages')]
32    #[ORM\JoinColumn(nullable: false)]
33    private User $owner;
34
35    #[ORM\Column(type: 'string', length: 255)]
36    private string $slug;
37
38    public function getId(): ?int
39    {
40        return $this->id;
41    }
42
43    public function getName(): ?string
44    {
45        return $this->name;
46    }
47
48    public function setName(string $name): self
49    {
50        $this->name = $name;
51
52        return $this;
53    }
54
55    public function getContent(): ?string
56    {
57        return $this->content;
58    }
59
60    public function setContent(string $content): self
61    {
62        $this->content = $content;
63
64        return $this;
65    }
66
67    public function getCreatedAt(): ?DateTimeImmutable
68    {
69        return $this->createdAt;
70    }
71
72    public function setCreatedAt(DateTimeImmutable $createdAt): self
73    {
74        $this->createdAt = $createdAt;
75
76        return $this;
77    }
78
79    public function getModifiedAt(): ?DateTimeImmutable
80    {
81        return $this->modifiedAt;
82    }
83
84    public function setModifiedAt(?DateTimeImmutable $modifiedAt): self
85    {
86        $this->modifiedAt = $modifiedAt;
87
88        return $this;
89    }
90
91    public function getOwner(): ?User
92    {
93        return $this->owner;
94    }
95
96    public function setOwner(?User $owner): self
97    {
98        $this->owner = $owner;
99
100        return $this;
101    }
102
103    public function getSlug(): ?string
104    {
105        return $this->slug;
106    }
107
108    public function setSlug(string $slug): self
109    {
110        $this->slug = $slug;
111
112        return $this;
113    }
114
115    #[ORM\PrePersist]
116    public function onPrePersist(): void
117    {
118        $slugger = new Slugger();
119        $slug = $slugger->slugify(string: $this->name);
120        $this->slug = $slug;
121
122        $this->createdAt = new DateTimeImmutable(datetime: 'now');
123    }
124
125    #[ORM\PreUpdate]
126    public function onPreUpdate(): void
127    {
128        $slugger = new Slugger();
129        $slug = $slugger->slugify(string: $this->name);
130        $this->slug = $slug;
131
132        $this->modifiedAt = new DateTimeImmutable(datetime: 'now');
133    }
134}