32 lines
641 B
PHP
32 lines
641 B
PHP
|
|
<?php
|
||
|
|
|
||
|
|
declare(strict_types=1);
|
||
|
|
|
||
|
|
namespace Domain\Models\ValueObjects;
|
||
|
|
|
||
|
|
use Shared\DDD\Models\Equatable;
|
||
|
|
|
||
|
|
final readonly class ProcessingCode implements \Stringable, Equatable
|
||
|
|
{
|
||
|
|
public function __construct(
|
||
|
|
public string $value,
|
||
|
|
) {
|
||
|
|
$trimmed = trim($this->value);
|
||
|
|
|
||
|
|
if ($trimmed === '') {
|
||
|
|
throw new \DomainException('GS1 value cannot be empty.');
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
#[\Override]
|
||
|
|
public function equals(mixed $other): bool
|
||
|
|
{
|
||
|
|
return $other instanceof self && $this->value === $other->value;
|
||
|
|
}
|
||
|
|
|
||
|
|
public function __toString(): string
|
||
|
|
{
|
||
|
|
return $this->value;
|
||
|
|
}
|
||
|
|
}
|