From 5f125280b7923793f93eaa8d4a8129e92540020f Mon Sep 17 00:00:00 2001 From: jake johns Date: Tue, 27 Dec 2016 14:52:34 -0500 Subject: [PATCH] Use immutable dates Replace nesbot/carbon with cakephp/chronos --- composer.json | 2 +- src/Traits/DateAwareTrait.php | 4 ++-- tests/EntityTest.php | 2 +- tests/Traits/DateAwareTest.php | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/composer.json b/composer.json index 44ce036..f746c4b 100644 --- a/composer.json +++ b/composer.json @@ -14,7 +14,7 @@ }, "require": { "php": ">=5.5", - "nesbot/carbon": "^1" + "cakephp/chronos": "^1.0" }, "require-dev": { "phpunit/phpunit": "^4.8|^5.0" diff --git a/src/Traits/DateAwareTrait.php b/src/Traits/DateAwareTrait.php index 5bd53a3..7940997 100644 --- a/src/Traits/DateAwareTrait.php +++ b/src/Traits/DateAwareTrait.php @@ -2,7 +2,7 @@ namespace Equip\Data\Traits; -use Carbon\Carbon; +use Cake\Chronos\Chronos; trait DateAwareTrait { @@ -15,7 +15,7 @@ trait DateAwareTrait */ public function date($key) { - return new Carbon($this->$key); + return new Chronos($this->$key); } /** diff --git a/tests/EntityTest.php b/tests/EntityTest.php index d585c83..8abf20e 100644 --- a/tests/EntityTest.php +++ b/tests/EntityTest.php @@ -39,7 +39,7 @@ public function testToArray() public function testDate() { - $this->assertInstanceOf('Carbon\Carbon', $this->entity->date('created_at')); + $this->assertInstanceOf('Cake\Chronos\Chronos', $this->entity->date('created_at')); } public function testJsonEncode() diff --git a/tests/Traits/DateAwareTest.php b/tests/Traits/DateAwareTest.php index 4ec9d35..8656855 100644 --- a/tests/Traits/DateAwareTest.php +++ b/tests/Traits/DateAwareTest.php @@ -15,7 +15,7 @@ protected function setUp() public function testDate() { $date = $this->object->date('at'); - $this->assertInstanceOf('Carbon\Carbon', $date); + $this->assertInstanceOf('Cake\Chronos\Chronos', $date); } public function testDateString()