code, 'items.code'); self::requirePositiveInt($this->amount, 'items.amount'); self::requirePositiveInt($this->quantity, 'items.quantity'); } public static function fromArray(array $item): self { return new self( code: (string) $item['code'], amount: (int) $item['amount'], quantity: (int) $item['quantity'], description: $item['description'] ?? null, ); } public function toArray(): array { return $this->filterFilledRecursive([ 'code' => $this->code, 'amount' => $this->amount, 'quantity' => $this->quantity, 'description' => $this->description, ]); } }