Event   A
last analyzed

Complexity

Total Complexity 8

Size/Duplication

Total Lines 83
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 8
eloc 18
dl 0
loc 83
ccs 0
cts 16
cp 0
rs 10
c 0
b 0
f 0

8 Methods

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