-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4fa1b93
commit 2341d1a
Showing
13 changed files
with
339 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Patchlevel\EventSourcing\Aggregate; | ||
|
||
use Ramsey\Uuid\Uuid; | ||
use Ramsey\Uuid\UuidInterface; | ||
|
||
trait RamseyAggregateIdBehaviour | ||
{ | ||
public function __construct( | ||
private readonly UuidInterface $id, | ||
) { | ||
} | ||
|
||
public static function fromString(string $id): self | ||
{ | ||
return new self(Uuid::fromString($id)); | ||
} | ||
|
||
public function toString(): string | ||
{ | ||
return $this->id->toString(); | ||
} | ||
|
||
public static function generate(): self | ||
{ | ||
return new self(Uuid::uuid7()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Patchlevel\EventSourcing\Aggregate; | ||
|
||
final class UuidAggregateRootId implements AggregateRootId | ||
{ | ||
use RamseyAggregateIdBehaviour; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Patchlevel\EventSourcing\Aggregate; | ||
|
||
trait ValueAggregateIdBehaviour | ||
{ | ||
public function __construct( | ||
private readonly string $id, | ||
) { | ||
} | ||
|
||
public static function fromString(string $id): self | ||
{ | ||
return new self($id); | ||
} | ||
|
||
public function toString(): string | ||
{ | ||
return $this->id; | ||
} | ||
} |
Oops, something went wrong.