ldc-arcadia-api/src/Domain/Models/ValueObjects/ServiceId.php

23 lines
460 B
PHP

<?php
declare(strict_types=1);
namespace Domain\Models\ValueObjects;
/**
* eg: 097
*/
final readonly class ServiceId
{
private const string PATTERN = '/^\d{1,}$/';
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
);
}
}
}