/** * @param CartId $cartId * @return Checkout * @throws CheckoutNotFoundException */ public function getForCart(CartId $cartId) : Checkout { $checkout = $this->entityManager->getRepository(Checkout::class)->findOneBy(['cartId.id' => $cartId]); if (is_null($checkout)) { throw CheckoutNotFoundException::byCartId($cartId); } return $checkout; }