Passed
Push — master ( 961468...052950 )
by Theo
01:43
created

CalendarEvent::addEvent()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2

Importance

Changes 0
Metric Value
cc 2
eloc 3
nc 2
nop 1
dl 0
loc 7
ccs 4
cts 4
cp 1
crap 2
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace CalendarBundle\Event;
4
5
use CalendarBundle\Entity\Event;
6
use Symfony\Component\EventDispatcher\Event as BaseEvent;
7
8
class CalendarEvent extends BaseEvent
9
{
10
    /**
11
     * @var \DateTimeInterface
12
     */
13
    protected $start;
14
15
    /**
16
     * @var \DateTimeInterface
17
     */
18
    protected $end;
19
20
    /**
21
     * @var array
22
     */
23
    protected $filters;
24
25
    /**
26
     * @var Event[]
27
     */
28
    protected $events = [];
29
30
    /**
31
     * @param \DateTimeInterface $start
32
     * @param \DateTimeInterface $end
33
     * @param array              $filters
34
     */
35 4
    public function __construct(
36
        \DateTimeInterface $start,
37
        \DateTimeInterface $end,
38
        array $filters
39
    ) {
40 4
        $this->start = $start;
41 4
        $this->end = $end;
42 4
        $this->filters = $filters;
43 4
    }
44
45
    /**
46
     * @return \DateTimeInterface
47
     */
48 1
    public function getStart(): \DateTimeInterface
49
    {
50 1
        return $this->start;
51
    }
52
53
    /**
54
     * @return \DateTimeInterface
55
     */
56 1
    public function getEnd(): \DateTimeInterface
57
    {
58 1
        return $this->end;
59
    }
60
61
    /**
62
     * @return array
63
     */
64 1
    public function getFilters(): array
65
    {
66 1
        return $this->filters;
67
    }
68
69
    /**
70
     * @param Event $event
71
     *
72
     * @return $this
73
     */
74 1
    public function addEvent(Event $event): self
75
    {
76 1
        if (!in_array($event, $this->events, true)) {
77 1
            $this->events[] = $event;
78
        }
79
80 1
        return $this;
81
    }
82
83
    /**
84
     * @return Event[]
85
     */
86 1
    public function getEvents(): array
87
    {
88 1
        return $this->events;
89
    }
90
}
91