Skip to content

Commit

Permalink
refactor: moves DomainCollection in the generic Type namespace
Browse files Browse the repository at this point in the history
  • Loading branch information
matiux committed Nov 23, 2022
1 parent 03224c4 commit 37c51ad
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 12 deletions.
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace DDDStarterPack\Aggregate\Domain;
namespace DDDStarterPack\Type;

use Iterator;

Expand All @@ -13,7 +13,7 @@
*
* @implements Iterator<array-key, T>
*/
class DomainCollection implements \Iterator, \Countable
class Collection implements \Iterator, \Countable
{
private int $position = 0;

Expand Down Expand Up @@ -82,7 +82,7 @@ public function toArray(): array
}

/**
* @template B of DomainCollection<T>
* @template B of Collection<T>
*
* @param B $collection
*
Expand Down
Expand Up @@ -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;
Expand Down
Expand Up @@ -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;
Expand Down
Expand Up @@ -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<MyData> */
private DomainCollection $collection;
/** @var Collection<MyData> */
private Collection $collection;

protected function setUp(): void
{
Expand All @@ -22,7 +22,7 @@ protected function setUp(): void

$items = [$a, $b];

$this->collection = new DomainCollection($items);
$this->collection = new Collection($items);
}

/**
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 37c51ad

Please sign in to comment.