for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
declare(strict_types=1);
namespace HDNET\Calendarize\Service;
use HDNET\Calendarize\Domain\DissectEvent;
use JMBTechnologyLimited\ICalDissect\ICalEvent;
use JMBTechnologyLimited\ICalDissect\ICalParser;
class DissectICalService extends AbstractService implements ICalServiceInterface
{
/**
* @inheritDoc
*/
public function getEvents(string $filename): array
$parser = new ICalParser();
if (!$parser->parseFromFile($filename)) {
// TODO: FileNotFoundException
throw new \RuntimeException('Unable to open or parse "' . $filename . '".', 1602345343);
}
// TODO: handle timezone???
$events = $parser->getEvents();
$wrapEvents = function (ICalEvent $event) {
return new DissectEvent($event);
};
return array_map($wrapEvents, $events);