refactor(shared): reorganize DDD core building blocks into sub-namespaces (Model, Port, Event)
This commit is contained in:
parent
8ce012d7f7
commit
fc368cdc46
23 changed files with 32 additions and 32 deletions
|
|
@ -8,9 +8,9 @@ use Domain\Models\ValueObjects\Employees\ArcadiaEmployeeId;
|
|||
use Domain\Models\ValueObjects\EstablishmentCode;
|
||||
use Domain\Models\ValueObjects\ServiceId;
|
||||
use Domain\Models\ValueObjects\SiteId;
|
||||
use Shared\DDD\Entity;
|
||||
use Shared\DDD\Model\Entity;
|
||||
|
||||
/** @implements \Shared\DDD\Entity<\Domain\Models\ValueObjects\Employees\ArcadiaEmployeeId> */
|
||||
/** @implements Entity<ArcadiaEmployeeId> */
|
||||
final readonly class Employee implements Entity
|
||||
{
|
||||
public function __construct(
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ use Domain\Models\ValueObjects\Inco\Composition\ReferenceMacronutrients;
|
|||
use Domain\Models\ValueObjects\Inco\Composition\SpecialCompounds;
|
||||
use Domain\Models\ValueObjects\Inco\Composition\Vitamins;
|
||||
use Domain\Models\ValueObjects\Inco\IncoId;
|
||||
use Shared\DDD\Entity;
|
||||
use Shared\DDD\Model\Entity;
|
||||
|
||||
/** @implements Entity<IncoCompositionId> */
|
||||
final readonly class IncoComposition implements Entity
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ use Domain\Models\ValueObjects\Inco\Ingredients;
|
|||
use Domain\Models\ValueObjects\Inco\Nutriscore;
|
||||
use Domain\Models\ValueObjects\Inco\PortionAmount;
|
||||
use Domain\Models\ValueObjects\Inco\StorageCondition;
|
||||
use Shared\DDD\Entity;
|
||||
use Shared\DDD\Model\Entity;
|
||||
|
||||
/** @implements Entity<IncoId> */
|
||||
final readonly class IncoSheet implements Entity
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ declare(strict_types=1);
|
|||
namespace Domain\Models\Entities\Inco;
|
||||
|
||||
use Domain\Models\ValueObjects\Inco\IncoId;
|
||||
use Shared\DDD\Entity;
|
||||
use Shared\DDD\Model\Entity;
|
||||
|
||||
/** @implements Entity<IncoId> */
|
||||
final readonly class IncoShortSheet implements Entity
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ declare(strict_types=1);
|
|||
|
||||
namespace Domain\Models\ValueObjects\Employees;
|
||||
|
||||
use Shared\DDD\EntityId;
|
||||
use Shared\DDD\Model\EntityId;
|
||||
|
||||
final readonly class ArcadiaEmployeeId extends EntityId
|
||||
{
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ declare(strict_types=1);
|
|||
|
||||
namespace Domain\Models\ValueObjects\Inco\Composition;
|
||||
|
||||
use Shared\DDD\EntityId;
|
||||
use Shared\DDD\Model\EntityId;
|
||||
|
||||
final readonly class IncoCompositionId extends EntityId
|
||||
{
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ declare(strict_types=1);
|
|||
|
||||
namespace Domain\Models\ValueObjects\Inco;
|
||||
|
||||
use Shared\DDD\EntityId;
|
||||
use Shared\DDD\Model\EntityId;
|
||||
|
||||
final readonly class IncoId extends EntityId
|
||||
{
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ use Domain\Models\Entities\Employee;
|
|||
use Domain\Models\ValueObjects\Employees\ArcadiaEmployeeId;
|
||||
use Domain\Models\ValueObjects\Employees\EmployeeFilter;
|
||||
use Domain\Models\ValueObjects\Employees\EmployeeSorter;
|
||||
use Shared\DDD\Directory;
|
||||
use Shared\DDD\Port\Directory;
|
||||
use Shared\Paginated;
|
||||
use Shared\Pagination;
|
||||
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ namespace Domain\Ports\Directories;
|
|||
use Domain\Models\Entities\Inco\Composition\IncoComposition;
|
||||
use Domain\Models\ValueObjects\Inco\Composition\IncoCompositionId;
|
||||
use Domain\Models\ValueObjects\Inco\IncoId;
|
||||
use Shared\DDD\Directory;
|
||||
use Shared\DDD\Port\Directory;
|
||||
|
||||
/** @extends Directory<IncoCompositionId, IncoComposition> */
|
||||
interface IncoCompositionDirectory extends Directory
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ use Domain\Models\ValueObjects\Inco\IncoId;
|
|||
use Domain\Models\ValueObjects\Inco\IncoIdQuery;
|
||||
use Domain\Models\ValueObjects\Inco\IncoSheetFilter;
|
||||
use Domain\Models\ValueObjects\Inco\IncoSheetSorter;
|
||||
use Shared\DDD\Directory;
|
||||
use Shared\DDD\Port\Directory;
|
||||
use Shared\Paginated;
|
||||
use Shared\Pagination;
|
||||
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ use Domain\Models\ValueObjects\Inco\IncoId;
|
|||
use Domain\Models\ValueObjects\Inco\IncoIdQuery;
|
||||
use Domain\Models\ValueObjects\Inco\IncoSheetFilter;
|
||||
use Domain\Models\ValueObjects\Inco\IncoSheetSorter;
|
||||
use Shared\DDD\Directory;
|
||||
use Shared\DDD\Port\Directory;
|
||||
use Shared\Paginated;
|
||||
use Shared\Pagination;
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Shared\DDD;
|
||||
namespace Shared\DDD\Event;
|
||||
|
||||
interface DomainEventDispatcher
|
||||
{
|
||||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Shared\DDD;
|
||||
namespace Shared\DDD\Event;
|
||||
|
||||
interface Event
|
||||
{
|
||||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Shared\DDD;
|
||||
namespace Shared\DDD\Model;
|
||||
|
||||
/**
|
||||
* @template T of EntityId
|
||||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Shared\DDD;
|
||||
namespace Shared\DDD\Model;
|
||||
|
||||
abstract readonly class EntityId implements \Stringable, Equatable
|
||||
{
|
||||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Shared\DDD;
|
||||
namespace Shared\DDD\Model;
|
||||
|
||||
interface Equatable
|
||||
{
|
||||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Shared\DDD;
|
||||
namespace Shared\DDD\Port;
|
||||
|
||||
/**
|
||||
* @template TId
|
||||
|
|
@ -2,11 +2,11 @@
|
|||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Shared\DDD;
|
||||
namespace Shared\DDD\Port;
|
||||
|
||||
/**
|
||||
* @template TId of \Shared\DDD\EntityId
|
||||
* @template TEntity of \Shared\DDD\Entity
|
||||
* @template TId of \Shared\DDD\Model\EntityId
|
||||
* @template TEntity of \Shared\DDD\Model\Entity
|
||||
*
|
||||
* @method TEntity|null find(TId $id)
|
||||
* @method void persist(TEntity $entity)
|
||||
|
|
@ -4,12 +4,12 @@ declare(strict_types=1);
|
|||
|
||||
namespace Tests\Architecture;
|
||||
|
||||
use Shared\DDD\Directory;
|
||||
use Shared\DDD\Entity;
|
||||
use Shared\DDD\Repository;
|
||||
use Shared\DDD\Model\Entity;
|
||||
use Shared\DDD\Port\Directory;
|
||||
use Shared\DDD\Port\Repository;
|
||||
|
||||
describe('Domain Architecture Rules', function (): void {
|
||||
arch('Domain Entities implement Shared\DDD\Entity')
|
||||
arch('Domain Entities implement Shared\DDD\Model\Entity')
|
||||
->expect('Domain\Models\Entities')
|
||||
->toImplement(Entity::class);
|
||||
|
||||
|
|
@ -23,11 +23,11 @@ describe('Domain Architecture Rules', function (): void {
|
|||
->classes()
|
||||
->toBeInterface();
|
||||
|
||||
arch('Domain Port Directories extend Shared\DDD\Directory')
|
||||
arch('Domain Port Directories extend Shared\DDD\Port\Directory')
|
||||
->expect('Domain\Ports\Directories')
|
||||
->toExtend(Directory::class);
|
||||
|
||||
arch('Domain Port Repositories extend Shared\DDD\Repository')
|
||||
arch('Domain Port Repositories extend Shared\DDD\Port\Repository')
|
||||
->expect('Domain\Ports\Repositories')
|
||||
->toExtend(Repository::class);
|
||||
|
||||
|
|
|
|||
|
|
@ -5,8 +5,8 @@ declare(strict_types=1);
|
|||
namespace Tests\Architecture;
|
||||
|
||||
use Presentation\Api\V1\Contracts\ApiResponse;
|
||||
use Shared\DDD\Directory;
|
||||
use Shared\DDD\Repository;
|
||||
use Shared\DDD\Port\Directory;
|
||||
use Shared\DDD\Port\Repository;
|
||||
|
||||
describe('Naming Conventions in Domain', function (): void {
|
||||
arch('Port Directory interfaces have Directory suffix')
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ use Domain\Models\ValueObjects\Inco\Composition\ReferenceMacronutrients;
|
|||
use Domain\Models\ValueObjects\Inco\Composition\SpecialCompounds;
|
||||
use Domain\Models\ValueObjects\Inco\Composition\Vitamins;
|
||||
use Domain\Models\ValueObjects\Inco\IncoId;
|
||||
use Shared\DDD\Entity;
|
||||
use Shared\DDD\Model\Entity;
|
||||
|
||||
covers(IncoComposition::class);
|
||||
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ use Domain\Models\ValueObjects\Inco\Allegations;
|
|||
use Domain\Models\ValueObjects\Inco\Brand;
|
||||
use Domain\Models\ValueObjects\Inco\IncoId;
|
||||
use Domain\Models\ValueObjects\Inco\Ingredients;
|
||||
use Shared\DDD\Entity;
|
||||
use Shared\DDD\Model\Entity;
|
||||
|
||||
covers(IncoSheet::class);
|
||||
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ declare(strict_types=1);
|
|||
|
||||
namespace Tests\Unit\Shared\DDD;
|
||||
|
||||
use Shared\DDD\EntityId;
|
||||
use Shared\DDD\Model\EntityId;
|
||||
|
||||
covers(EntityId::class);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue