add support for DateTimeImmutable
Adds support for DateTimeImmutable by using the shared DateTimeInterface which both this and DateTime implement.
This commit is contained in:
parent
7923bfef7a
commit
3f67dbe66f
@ -61,7 +61,7 @@ class CellTypeHelper
|
||||
public static function isDateTimeOrDateInterval($value)
|
||||
{
|
||||
return (
|
||||
$value instanceof \DateTime ||
|
||||
$value instanceof \DateTimeInterface ||
|
||||
$value instanceof \DateInterval
|
||||
);
|
||||
}
|
||||
|
@ -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));
|
||||
|
Loading…
x
Reference in New Issue
Block a user