Skip to content

Commit

Permalink
Make it easier to create non-aggregate root aggregate roots...
Browse files Browse the repository at this point in the history
  • Loading branch information
simensen committed Sep 27, 2023
1 parent ee498ef commit f76ca6a
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions src/AggregateRoot/AsNotAnAggregateRootBehavior.php
@@ -0,0 +1,32 @@
<?php

declare(strict_types=1);

namespace Dflydev\EventSauce\Support\AggregateRoot;

use EventSauce\EventSourcing\AggregateRoot;
use EventSauce\EventSourcing\AggregateRootId;
use EventSauce\EventSourcing\AggregateRootId as AggregateRootIdType;
use Generator;

/**
* @template T1 of AggregateRoot
* @template T2 of AggregateRootId
*/
trait AsNotAnAggregateRootBehavior
{
public function aggregateRootVersion(): int
{
throw new \RuntimeException('Aggregate root version is not implemented');
}

public function releaseEvents(): array
{
throw new \RuntimeException('Aggregate root tracks no events');
}

public static function reconstituteFromEvents(AggregateRootIdType $aggregateRootId, Generator $events): static
{
throw new \RuntimeException('Aggregate root cannot be reconstituted from events');
}
}

0 comments on commit f76ca6a

Please sign in to comment.