Passed
Pull Request — master (#14)
by Theo
01:52
created

CalendarEvent::getTimezone()   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 CalendarBundle\Event;
6
7
use CalendarBundle\Entity\Event;
8
use DateTimeInterface;
9
use Symfony\Component\EventDispatcher\Event as BaseEvent;
10
11
class CalendarEvent extends BaseEvent
0 ignored issues
show
Deprecated Code introduced by
The class Symfony\Component\EventDispatcher\Event has been deprecated: since Symfony 4.3, use "Symfony\Contracts\EventDispatcher\Event" instead ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

11
class CalendarEvent extends /** @scrutinizer ignore-deprecated */ BaseEvent
Loading history...
12
{
13
    /**
14
     * @var DateTimeInterface
15
     */
16
    protected $start;
17
18
    /**
19
     * @var DateTimeInterface
20
     */
21
    protected $end;
22
23
    /**
24
     * @var array
25
     */
26
    protected $filters;
27
28
    /**
29
     * @var Event[]
30
     */
31
    protected $events = [];
32
33
    /**
34
     * @var string|null
35
     */
36
    private $timezone;
37
38 4
    public function __construct(
39
        DateTimeInterface $start,
40
        DateTimeInterface $end,
41
        array $filters,
42
        ?string $timezone = null
43
    ) {
44 4
        $this->start = $start;
45 4
        $this->end = $end;
46 4
        $this->filters = $filters;
47 4
        $this->timezone = $timezone;
48 4
    }
49
50 1
    public function getStart(): DateTimeInterface
51
    {
52 1
        return $this->start;
53
    }
54
55 1
    public function getEnd(): DateTimeInterface
56
    {
57 1
        return $this->end;
58
    }
59
60 1
    public function getFilters(): array
61
    {
62 1
        return $this->filters;
63
    }
64
65 1
    public function addEvent(Event $event): self
66
    {
67 1
        if (!\in_array($event, $this->events, true)) {
68 1
            $this->events[] = $event;
69
        }
70
71 1
        return $this;
72
    }
73
74
    /**
75
     * @return Event[]
76
     */
77 1
    public function getEvents(): array
78
    {
79 1
        return $this->events;
80
    }
81
82
    public function getTimezone(): ?string
83
    {
84
        return $this->timezone;
85
    }
86
}
87