Test Failed
Pull Request — master (#14)
by Marek
02:09
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 Symfony\Component\EventDispatcher\Event as BaseEvent;
9
10
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

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