| Total Complexity | 5 |
| Total Lines | 36 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php declare(strict_types=1); |
||
| 13 | class AggregateId implements AggregateIdInterface |
||
| 14 | { |
||
| 15 | public const PATTERN = '/^\S$|\S.*\S$/'; |
||
| 16 | |||
| 17 | private string $identifier; |
||
| 18 | |||
| 19 | /** |
||
| 20 | * @param string $identifier |
||
| 21 | * @return static |
||
| 22 | */ |
||
| 23 | 8 | public static function fromNative($identifier): self |
|
| 24 | { |
||
| 25 | 8 | Assertion::regex($identifier, static::PATTERN, 'Invalid id format.'); |
|
| 26 | 8 | return new static($identifier); |
|
| 27 | } |
||
| 28 | |||
| 29 | 6 | public function toNative(): string |
|
| 30 | { |
||
| 31 | 6 | return $this->identifier; |
|
| 32 | } |
||
| 33 | |||
| 34 | /** @param static $comparator */ |
||
| 35 | 4 | public function equals($comparator): bool |
|
| 39 | } |
||
| 40 | |||
| 41 | 6 | public function __toString(): string |
|
| 44 | } |
||
| 45 | |||
| 46 | 8 | final protected function __construct(string $identifier) |
|
| 51 |