Code Coverage |
||||||||||
Classes and Traits |
Functions and Methods |
Lines |
||||||||
| Total | |
100.00% |
1 / 1 |
|
100.00% |
5 / 5 |
CRAP | |
100.00% |
8 / 8 |
| OrderId | |
100.00% |
1 / 1 |
|
100.00% |
5 / 5 |
7 | |
100.00% |
8 / 8 |
| generate | |
100.00% |
1 / 1 |
1 | |
100.00% |
1 / 1 |
|||
| fromString | |
100.00% |
1 / 1 |
1 | |
100.00% |
1 / 1 |
|||
| __construct | |
100.00% |
1 / 1 |
1 | |
100.00% |
2 / 2 |
|||
| toString | |
100.00% |
1 / 1 |
1 | |
100.00% |
1 / 1 |
|||
| equals | |
100.00% |
1 / 1 |
3 | |
100.00% |
3 / 3 |
|||
| <?php | |
| declare(strict_types=1); | |
| namespace App\Order\Domain\ValueObject; | |
| use App\Shared\ValueObjectInterface; | |
| use function get_class; | |
| use Ramsey\Uuid\Uuid; | |
| use Ramsey\Uuid\UuidInterface; | |
| final class OrderId implements ValueObjectInterface | |
| { | |
| private UuidInterface $uuid; | |
| public static function generate(): self | |
| { | |
| return new self(Uuid::uuid4()); | |
| } | |
| public static function fromString(string $orderId): self | |
| { | |
| return new self(Uuid::fromString($orderId)); | |
| } | |
| private function __construct(UuidInterface $uuid) | |
| { | |
| $this->uuid = $uuid; | |
| } | |
| public function toString(): string | |
| { | |
| return $this->uuid->toString(); | |
| } | |
| public function equals(ValueObjectInterface $other): bool | |
| { | |
| if (!$other instanceof self) { | |
| return false; | |
| } | |
| return get_class($this) === get_class($other) && $this->uuid->equals($other->uuid); | |
| } | |
| } |