Passed
Pull Request — master (#14)
by Marek
02:11
created

CalendarEvent   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 77
Duplicated Lines 0 %

Test Coverage

Coverage 90%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 18
c 2
b 0
f 0
dl 0
loc 77
ccs 18
cts 20
cp 0.9
rs 10
wmc 8

7 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 10 1
A getEvents() 0 3 1
A getStart() 0 3 1
A addEvent() 0 7 2
A getEnd() 0 3 1
A getTimezone() 0 3 1
A getFilters() 0 3 1
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 4
    public function __construct(
38
        \DateTimeInterface $start,
39
        \DateTimeInterface $end,
40
        array $filters,
41
        ?string $timezone = null
42
    ) {
43 4
        $this->start = $start;
44 4
        $this->end = $end;
45 4
        $this->filters = $filters;
46 4
        $this->timezone = $timezone;
47 4
    }
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