Calendar   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 43
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 9
dl 0
loc 43
ccs 9
cts 9
cp 1
rs 10
c 0
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A getData() 0 12 1
1
<?php
2
3
namespace Toiba\FullCalendarBundle\Service;
4
5
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
6
use Toiba\FullCalendarBundle\Event\CalendarEvent;
7
8
class Calendar
9
{
10
    /**
11
     * @var SerializerInterface
12
     */
13
    protected $serializer;
14
15
    /**
16
     * @var EventDispatcherInterface
17
     */
18
    protected $dispatcher;
19
20
    /**
21
     * @param SerializerInterface      $serializer
22
     * @param EventDispatcherInterface $dispatcher
23
     */
24 2
    public function __construct(
25
        SerializerInterface $serializer,
26
        EventDispatcherInterface $dispatcher
27
    ) {
28 2
        $this->serializer = $serializer;
29 2
        $this->dispatcher = $dispatcher;
30 2
    }
31
32
    /**
33
     * @param \DateTimeInterface $startDate
34
     * @param \DateTimeInterface $endDate
35
     * @param array              $filters
36
     *
37
     * @return string json
38
     */
39 1
    public function getData(
40
        \DateTimeInterface $startDate,
41
        \DateTimeInterface $endDate,
42
        array $filters = []
43
    ): string {
44
        /** @var CalendarEvent $event */
45 1
        $event = $this->dispatcher->dispatch(
46 1
            CalendarEvent::SET_DATA,
47 1
            new CalendarEvent($startDate, $endDate, $filters)
48
        );
49
50 1
        return $this->serializer->serialize($event->getEvents());
51
    }
52
}
53