/** * @param int $hour */ public function __construct($hour) { if (DayState::isDay($hour)) { $this->state = DayState::getInstance(); } else { $this->state = NightState::getInstance(); } }
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()); } }
public function doClock(Context $context, $time) { if (strtotime(service_start_time) <= strtotime($time) || strtotime($time) < strtotime(service_end_time)) { $context->changeState(DayState::getInstance()); } }
/** * @param ContextInterface $context * @param int $hour */ public function doClock(ContextInterface $context, $hour) { if (DayState::isDay($hour)) { $context->changeState(DayState::getInstance()); } }