Ejemplo n.º 1
0
 /**
  * @param int $hour
  */
 public function __construct($hour)
 {
     if (DayState::isDay($hour)) {
         $this->state = DayState::getInstance();
     } else {
         $this->state = NightState::getInstance();
     }
 }
Ejemplo n.º 2
0
 public function doClock(Context $context, $time)
 {
     if (strtotime($time) >= strtotime(service_start_time) && strtotime($time) < strtotime(lunch_start_time)) {
         $context->changeState(DayState::getInstance());
     }
     if (strtotime($time) >= strtotime(lunch_start_time) && strtotime($time) < strtotime(lunch_end_time)) {
         $context->changeState(LunchState::getInstance());
     }
     if (strtotime($time) >= strtotime(lunch_end_time) && strtotime($time) < strtotime(service_end_time)) {
         $context->changeState(DayState::getInstance());
     }
     if (strtotime($time) >= strtotime(service_end_time)) {
         $context->changeState(NightState::getInstance());
     }
 }
Ejemplo n.º 3
0
 public function doClock(Context $context, $time)
 {
     if (strtotime(service_start_time) <= strtotime($time) || strtotime($time) < strtotime(service_end_time)) {
         $context->changeState(DayState::getInstance());
     }
 }
Ejemplo n.º 4
0
 /**
  * @param ContextInterface $context
  * @param int              $hour
  */
 public function doClock(ContextInterface $context, $hour)
 {
     if (DayState::isDay($hour)) {
         $context->changeState(DayState::getInstance());
     }
 }