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

ICSExporter::exportEvent()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 18

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 10
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 18
ccs 10
cts 10
cp 1
rs 9.6666
c 0
b 0
f 0
cc 2
nc 2
nop 1
crap 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