item['id']; } public function getProductId(): ?int { return $this->item['id_product'] ?? null; } public function getVariationId(): ?int { return $this->item['id_variation'] ?? null; } public function getPieces(): int { return (int) $this->item['pieces']; } public function getThumbnail(): ?Thumbnail { $product = $this->item['product'] ?? null; if (!$product || empty($product->photoId)) { return null; } return new Thumbnail( (string) $product->photoId, $product->photoDescr ?? '', (string) (empty($product->photoDateUpdate) ? '' : strtotime($product->photoDateUpdate)), ); } public function getDescription(): ?string { return $this->item['descr']; } public function getProductTitle(): ?string { return $this->item['product']['title'] ?? null; } public function getUrl(): ?string { if (!$this->getProductId()) { return null; } return path('products', [ 'id' => $this->getProductId(), 'name' => StringUtil::slugify($this->getProductTitle() ?? $this->getDescription()), ]); } public function getTotalPrice(): Price { return $this->totalPrice ??= new Price( $this->item['total_price']['value_without_vat'], $this->item['total_price']['currency_object'], $this->item['total_price']['vat'], ); } public function getPiecePrice(): Price { return $this->piecePrice ??= new Price( $this->item['piece_price']['value_without_vat'], $this->item['piece_price']['currency_object'], $this->item['piece_price']['vat'], ); } public function getItemType(): string { return $this->item['item_type']; } public function toArray(): array { return $this->item; } public function offsetExists(mixed $offset): bool { return isset($this->item[$offset]); } public function offsetGet(mixed $offset): mixed { return $this->item[$offset]; } public function offsetSet(mixed $offset, mixed $value): void { $this->item[$offset] = $value; } public function offsetUnset(mixed $offset): void { unset($this->item[$offset]); } }