28 lines
557 B
PHP
28 lines
557 B
PHP
|
|
<?php
|
||
|
|
|
||
|
|
declare(strict_types=1);
|
||
|
|
|
||
|
|
namespace Domain\Models\ValueObjects;
|
||
|
|
|
||
|
|
use Shared\DDD\Models\Equatable;
|
||
|
|
|
||
|
|
final readonly class IncoCode implements Equatable
|
||
|
|
{
|
||
|
|
/**
|
||
|
|
* @throws \DomainException
|
||
|
|
*/
|
||
|
|
public function __construct(
|
||
|
|
public int $value,
|
||
|
|
) {
|
||
|
|
if ($this->value <= 0) {
|
||
|
|
throw new \DomainException('Inco Code must be a positive integer.');
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
#[\Override]
|
||
|
|
public function equals(mixed $other): bool
|
||
|
|
{
|
||
|
|
return $other instanceof self && $this->value === $other->value;
|
||
|
|
}
|
||
|
|
}
|