Conditions | 4 |
Paths | 4 |
Total Lines | 26 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
21 | public function getEvents(string $filename): array |
||
22 | { |
||
23 | $content = GeneralUtility::getUrl($filename); |
||
24 | if ($content === false) { |
||
25 | throw new UnableToGetEventsException('Unable to get "' . $filename . '".', 1603307743); |
||
26 | } |
||
27 | |||
28 | try { |
||
29 | $vcalendar = Reader::read( |
||
30 | $content, |
||
31 | Reader::OPTION_FORGIVING |
||
32 | ); |
||
33 | } catch (ParseException $e) { |
||
34 | // Rethrow the exception to abstract the type |
||
35 | throw new UnableToGetEventsException('Unable to parse invalid object.', 1603309056, $e); |
||
36 | } |
||
37 | |||
38 | /** @var VEvent[] $events */ |
||
39 | $events = []; |
||
40 | |||
41 | foreach ($vcalendar->VEVENT as $event) { |
||
42 | $events[] = new VObjectEventAdapter($event); |
||
43 | } |
||
44 | |||
45 | return $events; |
||
46 | } |
||
47 | } |
||
48 |