Passed
Push — master ( 31b9cb...154d5e )
by Nicolas
13:25
created

Comment::__toString()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 1
eloc 1
c 1
b 0
f 1
nc 1
nop 0
dl 0
loc 3
ccs 0
cts 2
cp 0
crap 2
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace App\Entity;
6
7
use Doctrine\ORM\Mapping as ORM;
8
use Gedmo\Timestampable\Traits\TimestampableEntity;
9
use Symfony\Component\Validator\Constraints as Assert;
10
11
/**
12
 * @ORM\Entity(repositoryClass="App\Repository\CommentRepository")
13
 * @ORM\Table(name="rw_comment")
14
 */
15
class Comment
16
{
17
    use TimestampableEntity;
18
19
    /**
20
     * @ORM\Id()
21
     * @ORM\GeneratedValue()
22
     * @ORM\Column(type="integer")
23
     */
24
    private ?int $id = null;
25
26
    /**
27
     * @ORM\Column(type="text")
28
     * @Assert\NotBlank(message="comment.body.not_blank")
29
     */
30
    private ?string $body = null;
31
32
    /**
33
     * @ORM\ManyToOne(targetEntity="App\Entity\User")
34
     */
35
    private ?User $author = null;
36
37
    /**
38
     * @ORM\ManyToOne(targetEntity="App\Entity\Article")
39
     */
40
    private ?Article $article = null;
41
42
    public function __toString(): string
43
    {
44
        return sprintf('%s', $this->body);
45
    }
46
47 2
    public function getId(): ?int
48
    {
49 2
        return $this->id;
50
    }
51
52 4
    public function getBody(): ?string
53
    {
54 4
        return $this->body;
55
    }
56
57 1
    public function setBody(?string $body): void
58
    {
59 1
        $this->body = $body;
60
    }
61
62 4
    public function getAuthor(): ?User
63
    {
64 4
        return $this->author;
65
    }
66
67 3
    public function setAuthor(?User $author): void
68
    {
69 3
        $this->author = $author;
70
    }
71
72
    public function getArticle(): ?Article
73
    {
74
        return $this->article;
75
    }
76
77 3
    public function setArticle(?Article $article): void
78
    {
79 3
        $this->article = $article;
80
    }
81
}
82