10) { throw new \DomainException('Code has to be between 6 and 10 chars length'); } if (! preg_match('/^[' . self::ALLOWED_CHARACTERS . ']+$/', $value)) { throw new \DomainException('Code contains invalid characters'); } } public function __toString(): string { return $this->value; } public function equals(mixed $other): bool { return $other instanceof self && $this->value === $other->value; } }