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

VObjectICalService::getEvents()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 18

Duplication

Lines 0
Ratio 0 %

Importance

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