ldc-cocotte/domain/Models/ValueObjects/OrderReference.php

26 lines
518 B
PHP
Raw Normal View History

2026-06-14 21:32:07 +02:00
<?php
declare(strict_types=1);
namespace Domain\Models\ValueObjects;
use Ramsey\Uuid\UuidInterface;
use Shared\Helpers\UuidHelper;
2026-06-14 21:32:07 +02:00
final readonly class OrderReference implements \Stringable
{
public function __construct(
public UuidInterface $value
2026-06-14 21:32:07 +02:00
) {
if (! UuidHelper::isV7($value)) {
throw new \DomainException('value must be a valid UUID v7');
2026-06-14 21:32:07 +02:00
}
}
#[\Override]
public function __toString(): string
{
return $this->value->toString();
2026-06-14 21:32:07 +02:00
}
}