Dumplie\Customer\Domain\Checkouts::add PHP Method

add() public method

public add ( Checkout $checkout )
$checkout Checkout
    public function add(Checkout $checkout);

Usage Example

Beispiel #1
0
 /**
  * @param NewCheckout $command
  * @throws CheckoutAlreadyExistsException
  * @throws InvalidArgumentException
  * @throws CartNotFoundException
  * @throws InvalidUUIDFormatException
  */
 public function handle(NewCheckout $command)
 {
     $cartId = new CartId($command->cartId());
     if (!$this->carts->exists($cartId)) {
         throw new CartNotFoundException();
     }
     $billingAddress = new Address($command->name(), $command->street(), $command->postCode(), $command->city(), $command->countryIso2Code());
     if ($this->checkouts->existsForCart($cartId)) {
         throw new CheckoutAlreadyExistsException();
     }
     $this->checkouts->add(new Checkout($cartId, $billingAddress));
 }