<?php
 namespace Eluceo\iCal\Util; use DateTimeImmutable; use DateTimeInterface; final class DateTimeImmutableFactory { public static function createFromInterface(DateTimeInterface $dateTime): DateTimeImmutable { if ($dateTime instanceof DateTimeImmutable) { return $dateTime; } return (new DateTimeImmutable('now', $dateTime->getTimezone())) ->setTimestamp($dateTime->getTimestamp()); } } 