<?php
 namespace Eluceo\iCal\Presentation\Factory; use Eluceo\iCal\Domain\ValueObject\DateTime; use Eluceo\iCal\Domain\ValueObject\PointInTime; use Eluceo\iCal\Domain\ValueObject\Timestamp; use Eluceo\iCal\Presentation\Component\Property; use Eluceo\iCal\Presentation\Component\Property\Value\DateTimeValue; use Eluceo\iCal\Presentation\Component\Property\Value\TextValue; class DateTimeFactory { public function createProperty(string $propertyName, PointInTime $pointInTime): Property { return new Property( $propertyName, new DateTimeValue($pointInTime), $this->getParameters($pointInTime) ); } private function getParameters(PointInTime $pointInTime): array { if ( $pointInTime instanceof DateTime && $pointInTime->hasDateTimeZone() && $pointInTime->getDateTimeZone()->getName() !== 'UTC' ) { return [ new Property\Parameter('TZID', new TextValue($pointInTime->getDateTimeZone()->getName())), ]; } return []; } } 