diff --git a/src/Domain/ValueObject/TimeSpan.php b/src/Domain/ValueObject/TimeSpan.php index a781ac63..c963fbea 100644 --- a/src/Domain/ValueObject/TimeSpan.php +++ b/src/Domain/ValueObject/TimeSpan.php @@ -14,15 +14,15 @@ final class TimeSpan extends Occurrence { private DateTime $begin; - private DateTime $end; + private ?DateTime $end; - public function __construct(DateTime $begin, DateTime $end) + public function __construct(DateTime $begin, ?DateTime $end = null) { $this->begin = $begin; $this->end = $end; } - public static function create(DateTime $begin, DateTime $end): self + public static function create(DateTime $begin, ?DateTime $end = null): self { return new static($begin, $end); } @@ -32,7 +32,7 @@ public function getBegin(): DateTime return $this->begin; } - public function getEnd(): DateTime + public function getEnd(): ?DateTime { return $this->end; } diff --git a/src/Presentation/Factory/EventFactory.php b/src/Presentation/Factory/EventFactory.php index 2f834b2a..e93bd640 100644 --- a/src/Presentation/Factory/EventFactory.php +++ b/src/Presentation/Factory/EventFactory.php @@ -176,7 +176,9 @@ private function getOccurrenceProperties(Occurrence $occurrence): Generator if ($occurrence instanceof TimeSpan) { yield $this->dateTimeFactory->createProperty('DTSTART', $occurrence->getBegin()); - yield $this->dateTimeFactory->createProperty('DTEND', $occurrence->getEnd()); + if ($occurrence->getEnd() !== null) { + yield $this->dateTimeFactory->createProperty('DTEND', $occurrence->getEnd()); + } } }