ldc-arcadia-api/src/Domain/Models/ValueObjects/Employees/ArcadiaEmployeeId.php

22 lines
503 B
PHP

<?php
declare(strict_types=1);
namespace Domain\Models\ValueObjects\Employees;
use Shared\DDD\EntityId;
final readonly class ArcadiaEmployeeId extends EntityId
{
private const string PATTERN = '/^\d{7,8}$/';
public function __construct(
public readonly string $value
) {
if (! preg_match(self::PATTERN, $value)) {
throw new \DomainException(
"Invalid value '{$value}' does not match pattern " . self::PATTERN
);
}
}
}