Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
75.00% |
3 / 4 |
|
75.00% |
3 / 4 |
CRAP | |
0.00% |
0 / 1 |
| BoundedContextDefinitionIdentifier | |
75.00% |
3 / 4 |
|
75.00% |
3 / 4 |
4.25 | |
0.00% |
0 / 1 |
| getRegularExpression | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| getReferenceFor | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| fromNameAndUlid | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| createRandom | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | |
| 3 | namespace Apie\Maker\BoundedContext\Identifiers; |
| 4 | |
| 5 | use Apie\Core\Attributes\FakeMethod; |
| 6 | use Apie\Core\Identifiers\Identifier; |
| 7 | use Apie\Core\Identifiers\IdentifierInterface; |
| 8 | use Apie\Core\Identifiers\Ulid; |
| 9 | use Apie\Core\ValueObjects\IsStringWithRegexValueObject; |
| 10 | use Apie\Maker\BoundedContext\Resources\BoundedContextDefinition; |
| 11 | use Faker\Generator; |
| 12 | use ReflectionClass; |
| 13 | |
| 14 | #[FakeMethod('createRandom')] |
| 15 | final class BoundedContextDefinitionIdentifier implements IdentifierInterface |
| 16 | { |
| 17 | use IsStringWithRegexValueObject; |
| 18 | |
| 19 | public static function getRegularExpression(): string |
| 20 | { |
| 21 | return '/^[a-z][a-z0-9]*\|[a-zA-Z0-9]{22}$/'; |
| 22 | } |
| 23 | |
| 24 | public static function getReferenceFor(): ReflectionClass |
| 25 | { |
| 26 | return new ReflectionClass(BoundedContextDefinition::class); |
| 27 | } |
| 28 | |
| 29 | public static function fromNameAndUlid(Identifier $name, Ulid $ulid): self |
| 30 | { |
| 31 | return new self($name->toNative() . '|' . $ulid->toNative()); |
| 32 | } |
| 33 | |
| 34 | public static function createRandom(Generator $faker): self |
| 35 | { |
| 36 | return self::fromNameAndUlid(Identifier::createRandom($faker), Ulid::createRandom()); |
| 37 | } |
| 38 | } |