/** * @param CartId $cartId * * @throws CartNotFoundException */ public function remove(CartId $cartId) { if (!$this->exists($cartId)) { throw CartNotFoundException::byId($cartId); } unset($this->carts[(string) $cartId]); }
/** * @param CartId $cartId * @return Cart * @throws CartNotFoundException */ public function getById(CartId $cartId) : Cart { $cart = $this->entityManager->getRepository(Cart::class)->findOneBy(['id.id' => $cartId]); if ($cart === null) { throw CartNotFoundException::byId($cartId); } return $cart; }