add support for DateTimeImmutable

Adds support for DateTimeImmutable by using the shared DateTimeInterface
which both this and DateTime implement.
This commit is contained in:
Rhodri Pugh 2021-05-24 19:39:33 +01:00
parent 7923bfef7a
commit 3f67dbe66f
2 changed files with 2 additions and 1 deletions

View File

@ -61,7 +61,7 @@ class CellTypeHelper
public static function isDateTimeOrDateInterval($value)
{
return (
$value instanceof \DateTime ||
$value instanceof \DateTimeInterface ||
$value instanceof \DateInterval
);
}

View File

@ -90,6 +90,7 @@ class CellTypeHelperTest extends TestCase
public function testIsDateOrInterval()
{
$this->assertTrue(CellTypeHelper::isDateTimeOrDateInterval(new \DateTime()));
$this->assertTrue(CellTypeHelper::isDateTimeOrDateInterval(new \DateTimeImmutable()));
$this->assertTrue(CellTypeHelper::isDateTimeOrDateInterval(new \DateInterval('P1D')));
$this->assertFalse(CellTypeHelper::isDateTimeOrDateInterval(true));