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