30 lines
590 B
PHP
30 lines
590 B
PHP
|
|
<?php
|
||
|
|
|
||
|
|
declare(strict_types=1);
|
||
|
|
|
||
|
|
namespace Shared\ValueObjects;
|
||
|
|
|
||
|
|
use Ramsey\Uuid\UuidInterface;
|
||
|
|
use Shared\Helpers\UuidHelper;
|
||
|
|
|
||
|
|
final readonly class CrmHashcode implements \Stringable
|
||
|
|
{
|
||
|
|
public string $value;
|
||
|
|
|
||
|
|
public function __construct(
|
||
|
|
UuidInterface $value,
|
||
|
|
) {
|
||
|
|
UuidHelper::validateUuid($value);
|
||
|
|
|
||
|
|
if (! UuidHelper::isV4($value)) {
|
||
|
|
throw new \DomainException('CrmHashcode is not a valid uuidv4');
|
||
|
|
}
|
||
|
|
$this->value = $value->toString();
|
||
|
|
}
|
||
|
|
|
||
|
|
public function __toString(): string
|
||
|
|
{
|
||
|
|
return $this->value;
|
||
|
|
}
|
||
|
|
}
|