/** * {@inheritDoc} */ public function isValid(ReferralInterface $referral, Event $event) { if (!$event instanceof OrderEvent) { throw new \LogicException('Event should be an instance of OrderEvent'); } $order = $event->getOrder(); if ($order->currencyID !== $this->_currency) { throw new \LogicException('Order currency does not match minimum order constraint currency'); } return $order->totalGross >= $this->getValue(); }
/** * {@inheritDoc} */ public function isValid(ReferralInterface $referral, Event $event) { if (!$event instanceof OrderEvent) { throw new \LogicException('Event should be an instance of OrderEvent'); } $orderDate = $event->getOrder()->authorship->createdAt()->format('Y-m-d'); $referralDate = $referral->getCreatedAt()->format('Y-m-d'); $diff = strtotime($orderDate) - strtotime($referralDate); $timedOut = $diff <= $this->_value; if (false === $timedOut) { $referral->setStatus(Statuses::EXPIRED); $this->_referralEdit->save($referral); } }