23 lines
485 B
PHP
23 lines
485 B
PHP
|
|
<?php
|
||
|
|
|
||
|
|
declare(strict_types=1);
|
||
|
|
|
||
|
|
namespace Domain\Models\ValueObjects\Coupon;
|
||
|
|
|
||
|
|
final readonly class CouponName
|
||
|
|
{
|
||
|
|
public function __construct(
|
||
|
|
public string $value,
|
||
|
|
) {
|
||
|
|
$trimmed = mb_trim($value);
|
||
|
|
|
||
|
|
if ($trimmed === '') {
|
||
|
|
throw new \DomainException('Coupon name cannot be empty.');
|
||
|
|
}
|
||
|
|
|
||
|
|
if (mb_strlen($trimmed) > 200) {
|
||
|
|
throw new \DomainException('Coupon name exceeds the maximum allowed length.');
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|