(float) \trim($temp[0] ?? '0'), 'lon' => (float) \trim($temp[1] ?? '0'), ]; \preg_match('/URL:(.*?)\n/', $match[1], $url); $event['url'] = $url[1] ?? null; // Check if this event is recurring if (\preg_match('/RRULE:(.*?)\n/', $match[1], $rruleMatch)) { $rrule = self::parseRRule($rruleMatch[1]); $event = \array_merge($event, $rrule); } $eventList[] = $event; } return $eventList; } /** * Parse rrule * * @param string $rruleString rrule string * * @return array * * @since 1.0.0 */ private static function parseRRule($rruleString) : array { $rrule = []; \preg_match('/FREQ=(.*?);/', $rruleString, $freqMatch); $rrule['freq'] = $freqMatch[1] ?? null; \preg_match('/INTERVAL=(.*?);/', $rruleString, $intervalMatch); $rrule['interval'] = $intervalMatch[1] ?? null; \preg_match('/BYMONTH=(.*?);/', $rruleString, $monthMatch); $rrule['bymonth'] = $monthMatch[1] ?? null; \preg_match('/BYMONTHDAY=(.*?);/', $rruleString, $monthdayMatch); $rrule['bymonthday'] = $monthdayMatch[1] ?? null; $rrule['count'] = \preg_match('/COUNT=(.*?);/', $rruleString, $countMatch) ? (int) ($countMatch[1] ?? 0) : null; $rrule['until'] = \preg_match('/UNTIL=(.*?);/', $rruleString, $untilMatch) ? $untilMatch[1] ?? null : null; return $rrule; } }