Failed Conditions
Push — master ( 0507ab...a124e1 )
by Sam
09:13
created

Comment::getEvent()   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 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
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 Application\Model;
6
7
use Application\Traits\HasDescription;
8
use Doctrine\ORM\Mapping as ORM;
9
10
/**
11
 * A news
12
 *
13
 * @ORM\Entity(repositoryClass="Application\Repository\CommentRepository")
14
 */
15
class Comment extends AbstractModel
16
{
17
    use HasDescription;
18
19
    /**
20
     * @var null|Event
21
     *
22
     * @ORM\ManyToOne(targetEntity="Event", inversedBy="comments")
23
     * @ORM\JoinColumns({
24
     *     @ORM\JoinColumn(nullable=true, onDelete="CASCADE")
25
     * })
26
     */
27
    private $event;
28
29
    /**
30
     * Set event
31
     *
32
     * @param null|Event $event
33
     */
34
    public function setEvent(?Event $event): void
35
    {
36
        if ($this->event) {
37
            $this->event->commentRemoved($this);
38
        }
39
40
        $this->event = $event;
41
42
        if ($this->event) {
43
            $this->event->commentAdded($this);
44
        }
45
    }
46
47
    /**
48
     * Get event
49
     *
50
     * @return null|Event
51
     */
52
    public function getEvent(): ?Event
53
    {
54
        return $this->event;
55
    }
56
57
    /**
58
     * @var null|News
59
     *
60
     * @ORM\ManyToOne(targetEntity="News", inversedBy="comments")
61
     * @ORM\JoinColumns({
62
     *     @ORM\JoinColumn(nullable=true, onDelete="CASCADE")
63
     * })
64
     */
65
    private $news;
66
67
    /**
68
     * Set news
69
     *
70
     * @param null|News $news
71
     */
72
    public function setNews(?News $news): void
73
    {
74
        if ($this->news) {
75
            $this->news->commentRemoved($this);
76
        }
77
78
        $this->news = $news;
79
80
        if ($this->news) {
81
            $this->news->commentAdded($this);
82
        }
83
    }
84
85
    /**
86
     * Get news
87
     *
88
     * @return null|News
89
     */
90
    public function getNews(): ?News
91
    {
92
        return $this->news;
93
    }
94
}
95