Completed
Pull Request — master (#443)
by
unknown
02:03
created

VObjectICalService   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 4
dl 0
loc 25
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A getEvents() 0 18 2
1
<?php
2
3
declare(strict_types=1);
4
namespace HDNET\Calendarize\Service;
5
6
use HDNET\Calendarize\Domain\VObjectEvent;
7
use Sabre\VObject\Reader;
8
use TYPO3\CMS\Core\Utility\GeneralUtility;
9
10
class VObjectICalService extends AbstractService implements ICalServiceInterface
11
{
12
13
    /**
14
     * @inheritDoc
15
     */
16
    public function getEvents(string $filename): array
17
    {
18
        $vcalendar = Reader::read(
19
            GeneralUtility::getUrl($filename),
20
            Reader::OPTION_FORGIVING
21
        );
22
        // TODO: FileNotFound Exception
23
        // TODO: handle timezone???
24
25
        /** @var \Sabre\VObject\Component\VEvent[] $events */
26
        $events = [];
27
28
        foreach ($vcalendar->VEVENT as $event) {
29
            $events[] = new VObjectEvent($event);
30
        }
31
32
        return $events;
33
    }
34
}
35