Completed
Push — master ( 7e66ea...6a4de9 )
by Olivier
01:44
created

ICSExporter   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 2
dl 0
loc 21
ccs 10
cts 10
cp 1
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A exportEvent() 0 18 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Shapin\Calendar;
6
7
use Sabre\VObject;
8
use Shapin\Calendar\Model\Calendar;
9
use Shapin\Calendar\Model\Event;
10
use Shapin\Calendar\Model\RecurrenceRule;
11
12
class ICSExporter
13
{
14 1
    public function exportEvent(Event $event): string
15
    {
16
        $data = [
17 1
            'SUMMARY' => $event->getSummary(),
18 1
            'DESCRIPTION' => $event->getDescription(),
19 1
            'DTSTART' => $event->getStartAt(),
20 1
            'DTEND'   => $event->getEndAt(),
21
        ];
22 1
        if (null !== $event->getClassification()) {
23 1
            $data['CLASS'] = $event->getClassification();
24
        }
25
26 1
        $vcalendar = new VObject\Component\VCalendar([
27 1
            'VEVENT' => $data,
28
        ]);
29
30 1
        return $vcalendar->serialize();
31
    }
32
}
33