Total Complexity | 11 |
Total Lines | 99 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
10 | class Comment |
||
11 | { |
||
12 | /** |
||
13 | * @ORM\Id |
||
14 | * @ORM\GeneratedValue |
||
15 | * @ORM\Column(type="integer") |
||
16 | */ |
||
17 | private $id; |
||
18 | |||
19 | /** |
||
20 | * @ORM\ManyToOne(targetEntity=User::class) |
||
21 | * @ORM\JoinColumn(nullable=false, onDelete="CASCADE") |
||
22 | */ |
||
23 | private $user; |
||
24 | |||
25 | /** |
||
26 | * @ORM\Column(type="text") |
||
27 | */ |
||
28 | private $body; |
||
29 | |||
30 | /** |
||
31 | * @ORM\Column(type="datetime") |
||
32 | */ |
||
33 | private $createdAt; |
||
34 | |||
35 | /** |
||
36 | * @ORM\ManyToOne(targetEntity=Post::class, inversedBy="comments") |
||
37 | * @ORM\JoinColumn(nullable=false, onDelete="CASCADE") |
||
38 | */ |
||
39 | private $post; |
||
40 | |||
41 | /** |
||
42 | * @ORM\Column(type="boolean") |
||
43 | */ |
||
44 | private $approved = false; |
||
45 | |||
46 | public function __construct(User $user, string $body) |
||
47 | { |
||
48 | $this->user = $user; |
||
49 | $this->body = $body; |
||
50 | $this->createdAt = new \DateTime('now'); |
||
51 | } |
||
52 | |||
53 | public function getId(): ?int |
||
54 | { |
||
55 | return $this->id; |
||
56 | } |
||
57 | |||
58 | public function getUser(): User |
||
59 | { |
||
60 | return $this->user; |
||
61 | } |
||
62 | |||
63 | public function getBody(): ?string |
||
64 | { |
||
65 | return $this->body; |
||
66 | } |
||
67 | |||
68 | public function setBody(string $body): self |
||
69 | { |
||
70 | $this->body = $body; |
||
71 | |||
72 | return $this; |
||
73 | } |
||
74 | |||
75 | public function getCreatedAt(): ?\DateTimeInterface |
||
76 | { |
||
77 | return $this->createdAt; |
||
78 | } |
||
79 | |||
80 | public function setCreatedAt(\DateTimeInterface $createdAt): self |
||
81 | { |
||
82 | $this->createdAt = $createdAt; |
||
83 | |||
84 | return $this; |
||
85 | } |
||
86 | |||
87 | public function getPost(): ?Post |
||
88 | { |
||
89 | return $this->post; |
||
90 | } |
||
91 | |||
92 | public function setPost(?Post $post): self |
||
97 | } |
||
98 | |||
99 | public function getApproved(): ?bool |
||
100 | { |
||
101 | return $this->approved; |
||
102 | } |
||
103 | |||
104 | public function setApproved(bool $approved): self |
||
109 | } |
||
110 | } |
||
111 |