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

CalendarEvent   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 81
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 15
dl 0
loc 81
ccs 17
cts 17
cp 1
rs 10
c 0
b 0
f 0
wmc 7

6 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 8 1
A getEvents() 0 3 1
A getStart() 0 3 1
A addEvent() 0 7 2
A getEnd() 0 3 1
A getFilters() 0 3 1
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