-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- added interface `AggregateIdInterface` - class `AggregateId` is marked as deprecated and will be removed in next commits - added interface `CompositeAggregateIdInterface` and trait `CompositeAggregateIdTrait` - the whole project using now `AggregateIdInterface` instead of `AggregateId` class - removed event `AggregateDeleted` and trait `DeletableAggregateRootTrait` - User and Mail domains implements own deleting logic - added support for composite aggregate ids in event streams - all domain events now must implement own method `getAggregateId()`
- Loading branch information
Showing
51 changed files
with
764 additions
and
207 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
45 changes: 0 additions & 45 deletions
45
src/ArchitectureBundle/Domain/DeletableAggregateRootTrait.php
This file was deleted.
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 was deleted.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace SixtyEightPublishers\ArchitectureBundle\Domain\Exception; | ||
|
||
use stdClass; | ||
use function get_class; | ||
use function gettype; | ||
use function implode; | ||
use function is_array; | ||
use function is_int; | ||
use function is_object; | ||
|
||
final class Typehint | ||
{ | ||
public function __construct( | ||
public readonly string $value, | ||
public readonly bool $isInstance, | ||
) {} | ||
|
||
public static function fromVariable(mixed $variable): self | ||
{ | ||
[$value, $isInstance] = self::getVariableType( | ||
variable: $variable, | ||
); | ||
|
||
return new self( | ||
value: $value, | ||
isInstance: $isInstance, | ||
); | ||
} | ||
|
||
public function __toString(): string | ||
{ | ||
return $this->value; | ||
} | ||
|
||
/** | ||
* @return array{ | ||
* 0: string, | ||
* 1: bool, | ||
* } | ||
*/ | ||
private static function getVariableType(mixed $variable): array | ||
{ | ||
if (is_object($variable) && stdClass::class !== get_class($variable)) { | ||
$type = get_class($variable); | ||
$isInstance = true; | ||
} else { | ||
$type = gettype($variable); | ||
$isInstance = false; | ||
} | ||
|
||
$type = ['boolean' => 'bool', 'integer' => 'int', 'double' => 'float', 'NULL' => 'null'][$type] ?? $type; | ||
|
||
if ('array' === $type && is_array($variable)) { | ||
$structure = []; | ||
|
||
foreach ($variable as $k => $v) { | ||
$structure[] = (is_int($k) ? $k : ($k . "'$k'")) . ': ' . self::getVariableType($v)[0]; | ||
} | ||
|
||
$type = 'array{' . implode(', ', $structure) . '}'; | ||
} | ||
|
||
return [ | ||
$type, | ||
$isInstance, | ||
]; | ||
} | ||
} |
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
12 changes: 12 additions & 0 deletions
12
src/ArchitectureBundle/Domain/ValueObject/AggregateIdInterface.php
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,12 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace SixtyEightPublishers\ArchitectureBundle\Domain\ValueObject; | ||
|
||
interface AggregateIdInterface extends ValueObjectInterface | ||
{ | ||
public static function isValid(mixed $native): bool; | ||
|
||
public function toString(): string; | ||
} |
Oops, something went wrong.