From 8901b23d58171892e3c148552a0a7bf88a939107 Mon Sep 17 00:00:00 2001 From: madflow Date: Thu, 21 Dec 2017 08:52:34 +0100 Subject: [PATCH] implement Cell:isDate() for unification --- src/Spout/Common/Entity/Cell.php | 8 ++++++++ tests/Spout/Common/Entity/CellTest.php | 9 +++++++++ 2 files changed, 17 insertions(+) diff --git a/src/Spout/Common/Entity/Cell.php b/src/Spout/Common/Entity/Cell.php index f1f7c1d..73e7040 100644 --- a/src/Spout/Common/Entity/Cell.php +++ b/src/Spout/Common/Entity/Cell.php @@ -182,6 +182,14 @@ class Cell return $this->type === self::TYPE_STRING; } + /** + * @return bool + */ + public function isDate() + { + return $this->type === self::TYPE_DATE; + } + /** * @return bool */ diff --git a/tests/Spout/Common/Entity/CellTest.php b/tests/Spout/Common/Entity/CellTest.php index 7b97850..e5f763a 100644 --- a/tests/Spout/Common/Entity/CellTest.php +++ b/tests/Spout/Common/Entity/CellTest.php @@ -54,6 +54,15 @@ class CellTest extends \PHPUnit\Framework\TestCase $this->assertTrue((new Cell(false))->isBoolean()); } + /** + * @return void + */ + public function testCellTypeDate() + { + $this->assertTrue((new Cell(new \DateTime()))->isDate()); + $this->assertTrue((new Cell(new \DateInterval('P2Y4DT6H8M')))->isDate()); + } + /** * @return void */