<?php
 namespace Eluceo\iCal\Domain\ValueObject; use DateInterval; use DateTimeImmutable as PhpDateTimeImmutable; use DateTimeInterface as PhpDateTimeInterface; use Eluceo\iCal\Util\DateTimeImmutableFactory; abstract class PointInTime { private PhpDateTimeImmutable $dateTime; public function __construct(?PhpDateTimeInterface $dateTime = null) { if ($dateTime === null) { $dateTime = new PhpDateTimeImmutable(); } $this->dateTime = DateTimeImmutableFactory::createFromInterface($dateTime); } public function getDateTime(): PhpDateTimeImmutable { return $this->dateTime; } public function add(DateInterval $interval): self { $new = clone $this; $new->dateTime = $new->dateTime->add($interval); return $new; } } 