示例#1
0
 public function isPaymentTypeAvailable(PaymentType $paymentType)
 {
     switch ($paymentType->getValue()) {
         case PaymentType::CASH:
             return $this->cashPaymentAvailable;
         case PaymentType::BANK:
             return $this->bankPaymentAvailable;
         case PaymentType::CARD:
             return $this->cardPaymentAvailable;
         default:
             throw new \LogicException();
     }
 }
示例#2
0
文件: Order.php 项目: shophp/shophp
 public function __construct(Cart $cart, $number, PaymentType $paymentType)
 {
     if (count($cart->getItems()) === 0) {
         throw new InvalidEnumException('Cannot create order from empty cart.');
     }
     if (strlen($number) !== self::NUMBER_LENGTH) {
         throw new EntityInvalidArgumentException(sprintf('Order number length must be exactly %d characters.', self::NUMBER_LENGTH));
     }
     $this->number = $number;
     $this->paymentType = $paymentType->getValue();
     $cart->setOrder($this);
     $this->cart = $cart;
 }