Dumplie\Customer\Domain\Exception\CheckoutNotFoundException::byCartId PHP Method

byCartId() public static method

public static byCartId ( CartId $cartId ) : CheckoutNotFoundException
$cartId Dumplie\Customer\Domain\CartId
return CheckoutNotFoundException
    public static function byCartId(CartId $cartId) : CheckoutNotFoundException
    {
        return new self(sprintf('Checkout for cart id "%s" does not exists.', (string) $cartId));
    }

Usage Example

Beispiel #1
0
 /**
  * @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;
 }
CheckoutNotFoundException