Passed
Push — master ( a8b983...5b3176 )
by Adrien
10:48
created

Event::commentRemoved()   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 0
Metric Value
cc 1
eloc 1
c 0
b 0
f 0
nc 1
nop 1
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\HasDate;
8
use Doctrine\Common\Collections\ArrayCollection;
9
use Doctrine\Common\Collections\Collection;
10
use Doctrine\ORM\Mapping as ORM;
11
use Ecodev\Felix\Model\Traits\HasName;
12
13
/**
14
 * An event
15
 *
16
 * @ORM\Entity(repositoryClass="Application\Repository\EventRepository")
17
 */
18
class Event extends AbstractModel
19
{
20
    use HasName;
21
    use HasDate;
22
23
    /**
24
     * @var Collection
25
     * @ORM\OneToMany(targetEntity="Comment", mappedBy="event")
26
     */
27
    private $comments;
28
29
    public function __construct()
30
    {
31
        $this->comments = new ArrayCollection();
32
    }
33
34
    /**
35
     * @var string
36
     * @ORM\Column(type="string", length=191)
37
     */
38
    private $place;
39
40
    /**
41
     * Set place
42
     *
43
     * @param string $place
44
     */
45
    public function setPlace($place): void
46
    {
47
        $this->place = $place;
48
    }
49
50
    /**
51
     * Get place
52
     */
53
    public function getPlace(): string
54
    {
55
        return (string) $this->place;
56
    }
57
58
    /**
59
     * @var string
60
     * @ORM\Column(type="string", length=191)
61
     */
62
    private $type;
63
64
    /**
65
     * Set type
66
     *
67
     * @param string $type
68
     */
69
    public function setType($type): void
70
    {
71
        $this->type = $type;
72
    }
73
74
    /**
75
     * Get type
76
     */
77
    public function getType(): string
78
    {
79
        return (string) $this->type;
80
    }
81
82
    /**
83
     * Get comments sent to the event
84
     */
85
    public function getComments(): Collection
86
    {
87
        return $this->comments;
88
    }
89
90
    /**
91
     * Notify the event that it has a new comment
92
     * This should only be called by Comment::setEvent()
93
     */
94
    public function commentAdded(Comment $comment): void
95
    {
96
        $this->comments->add($comment);
97
    }
98
99
    /**
100
     * Notify the event that a comment was removed
101
     * This should only be called by Comment::setEvent()
102
     */
103
    public function commentRemoved(Comment $comment): void
104
    {
105
        $this->comments->removeElement($comment);
106
    }
107
}
108