evwiki/src/Domain/Model/Id/CarModelId.php
2025-06-04 07:23:31 +02:00

29 lines
621 B
PHP

<?php
namespace App\Domain\Model\Id;
final readonly class CarModelId
{
public function __construct(
public string $value
) {
if (!str_starts_with($value, 'carmodel_')) {
throw new \InvalidArgumentException('CarModelId must start with "carmodel_"');
}
}
public function __toString(): string
{
return $this->value;
}
public function equals(CarModelId $other): bool
{
return $this->value === $other->value;
}
public static function generate(): CarModelId
{
return new CarModelId(uniqid('carmodel_', true));
}
}