2026-08-12 15:45:29 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
2026-08-14 15:38:10 +02:00
|
|
|
namespace Domain\Models\ValueObjects\Employees;
|
2026-08-12 15:45:29 +02:00
|
|
|
|
2026-08-17 10:31:28 +02:00
|
|
|
use Shared\DDD\Model\EntityId;
|
2026-08-12 15:45:29 +02:00
|
|
|
|
2026-08-31 17:29:18 +02:00
|
|
|
final readonly class SiRhMatricule extends EntityId
|
2026-08-12 15:45:29 +02:00
|
|
|
{
|
2026-08-17 09:41:10 +02:00
|
|
|
private const string PATTERN = '/^\d{7,8}$/';
|
2026-08-12 15:45:29 +02:00
|
|
|
|
|
|
|
|
public function __construct(
|
2026-08-17 09:42:21 +02:00
|
|
|
string $value
|
2026-08-12 15:45:29 +02:00
|
|
|
) {
|
2026-08-17 09:42:21 +02:00
|
|
|
parent::__construct($value);
|
|
|
|
|
|
2026-08-12 15:45:29 +02:00
|
|
|
if (! preg_match(self::PATTERN, $value)) {
|
|
|
|
|
throw new \DomainException(
|
|
|
|
|
"Invalid value '{$value}' does not match pattern " . self::PATTERN
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|