From 37c51ade2ab875aba9cd1d6f30e5183d367c6f53 Mon Sep 17 00:00:00 2001 From: Matteo Galacci Date: Wed, 23 Nov 2022 12:33:12 +0100 Subject: [PATCH] refactor: moves DomainCollection in the generic Type namespace --- .../DomainCollection.php => Type/Collection.php} | 6 +++--- .../Type/{ => Doctrine}/DoctrineDate.php | 3 ++- .../Type/{ => Doctrine}/DoctrineDateTimeRFC.php | 3 ++- .../CollectionTest.php} | 14 +++++++------- 4 files changed, 14 insertions(+), 12 deletions(-) rename src/Matiux/DDDStarterPack/{Aggregate/Domain/DomainCollection.php => Type/Collection.php} (91%) rename src/Matiux/DDDStarterPack/Type/{ => Doctrine}/DoctrineDate.php (95%) rename src/Matiux/DDDStarterPack/Type/{ => Doctrine}/DoctrineDateTimeRFC.php (96%) rename tests/Unit/DDDStarterPack/{Aggregate/Domain/DomainCollectionTest.php => Type/CollectionTest.php} (77%) diff --git a/src/Matiux/DDDStarterPack/Aggregate/Domain/DomainCollection.php b/src/Matiux/DDDStarterPack/Type/Collection.php similarity index 91% rename from src/Matiux/DDDStarterPack/Aggregate/Domain/DomainCollection.php rename to src/Matiux/DDDStarterPack/Type/Collection.php index 9393d6c..5425d71 100644 --- a/src/Matiux/DDDStarterPack/Aggregate/Domain/DomainCollection.php +++ b/src/Matiux/DDDStarterPack/Type/Collection.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace DDDStarterPack\Aggregate\Domain; +namespace DDDStarterPack\Type; use Iterator; @@ -13,7 +13,7 @@ * * @implements Iterator */ -class DomainCollection implements \Iterator, \Countable +class Collection implements \Iterator, \Countable { private int $position = 0; @@ -82,7 +82,7 @@ public function toArray(): array } /** - * @template B of DomainCollection + * @template B of Collection * * @param B $collection * diff --git a/src/Matiux/DDDStarterPack/Type/DoctrineDate.php b/src/Matiux/DDDStarterPack/Type/Doctrine/DoctrineDate.php similarity index 95% rename from src/Matiux/DDDStarterPack/Type/DoctrineDate.php rename to src/Matiux/DDDStarterPack/Type/Doctrine/DoctrineDate.php index 89e7321..cfe9ebb 100644 --- a/src/Matiux/DDDStarterPack/Type/DoctrineDate.php +++ b/src/Matiux/DDDStarterPack/Type/Doctrine/DoctrineDate.php @@ -2,8 +2,9 @@ declare(strict_types=1); -namespace DDDStarterPack\Type; +namespace DDDStarterPack\Type\Doctrine; +use DDDStarterPack\Type\Date; use Doctrine\DBAL\Platforms\AbstractPlatform; use Doctrine\DBAL\Types\ConversionException; use Doctrine\DBAL\Types\DateType; diff --git a/src/Matiux/DDDStarterPack/Type/DoctrineDateTimeRFC.php b/src/Matiux/DDDStarterPack/Type/Doctrine/DoctrineDateTimeRFC.php similarity index 96% rename from src/Matiux/DDDStarterPack/Type/DoctrineDateTimeRFC.php rename to src/Matiux/DDDStarterPack/Type/Doctrine/DoctrineDateTimeRFC.php index b91694b..d34636e 100644 --- a/src/Matiux/DDDStarterPack/Type/DoctrineDateTimeRFC.php +++ b/src/Matiux/DDDStarterPack/Type/Doctrine/DoctrineDateTimeRFC.php @@ -2,8 +2,9 @@ declare(strict_types=1); -namespace DDDStarterPack\Type; +namespace DDDStarterPack\Type\Doctrine; +use DDDStarterPack\Type\DateTimeRFC; use Doctrine\DBAL\Platforms\AbstractPlatform; use Doctrine\DBAL\Types\ConversionException; use Doctrine\DBAL\Types\DateTimeImmutableType; diff --git a/tests/Unit/DDDStarterPack/Aggregate/Domain/DomainCollectionTest.php b/tests/Unit/DDDStarterPack/Type/CollectionTest.php similarity index 77% rename from tests/Unit/DDDStarterPack/Aggregate/Domain/DomainCollectionTest.php rename to tests/Unit/DDDStarterPack/Type/CollectionTest.php index d41fe69..cceadc8 100644 --- a/tests/Unit/DDDStarterPack/Aggregate/Domain/DomainCollectionTest.php +++ b/tests/Unit/DDDStarterPack/Type/CollectionTest.php @@ -2,15 +2,15 @@ declare(strict_types=1); -namespace Tests\Unit\DDDStarterPack\Aggregate\Domain; +namespace Tests\Unit\DDDStarterPack\Type; -use DDDStarterPack\Aggregate\Domain\DomainCollection; +use DDDStarterPack\Type\Collection; use PHPUnit\Framework\TestCase; -class DomainCollectionTest extends TestCase +class CollectionTest extends TestCase { - /** @var DomainCollection */ - private DomainCollection $collection; + /** @var Collection */ + private Collection $collection; protected function setUp(): void { @@ -22,7 +22,7 @@ protected function setUp(): void $items = [$a, $b]; - $this->collection = new DomainCollection($items); + $this->collection = new Collection($items); } /** @@ -62,7 +62,7 @@ public function it_should_be_mergeable(): void $c = new MyData(); $c->data = true; - $collection2 = new DomainCollection([$c]); + $collection2 = new Collection([$c]); $mergedCollection = $this->collection->merge($collection2); self::assertCount(3, $mergedCollection);