/** * @param Basket $basket * @param Product $product * @return BasketItem * @throws BasketItemNotFound */ public function findBasketItem(Basket $basket, Product $product) { $data = ['basket' => $basket->getId(), 'product' => $product->getId()]; $item = $this->_getItem($data); if (empty($item)) { throw new BasketItemNotFound($this->_newInstance($data)); } return $item; }
/** * @param array $data * @return string */ protected function _getId(array $data) { return Basket::calculateId($data); }
public function __construct(Basket $basket, Exception $previous = null) { parent::__construct('Basket #' . $basket->getId() . ' not found', 404, $previous); }