ICSExporter   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 3
dl 0
loc 25
ccs 12
cts 12
cp 1
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A exportEvent() 0 22 3
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 2
    public function exportEvent(Event $event): string
15
    {
16
        $data = [
17 2
            'SUMMARY' => $event->getSummary(),
18 2
            'DESCRIPTION' => $event->getDescription(),
19 2
            'DTSTART' => $event->getStartAt(),
20 2
            'DTEND'   => $event->getEndAt(),
21
        ];
22 2
        if (null !== $event->getClassification()) {
23 1
            $data['CLASS'] = $event->getClassification();
24
        }
25
26 2
        if ($event->isRecurring()) {
27 1
            $data['RRULE'] = $event->getRecurrenceRule()->getParts();
28
        }
29
30 2
        $vcalendar = new VObject\Component\VCalendar([
31 2
            'VEVENT' => $data,
32
        ]);
33
34 2
        return $vcalendar->serialize();
35
    }
36
}
37