izzum\examples\trafficlight\TrafficLight::isReadyToSwitch PHP Method

isReadyToSwitch() public method

public isReadyToSwitch ( )
    public function isReadyToSwitch()
    {
        $output = false;
        switch ($this->color) {
            case 'red':
                if ($this->onColorFor(self::TIME_RED)) {
                    $output = true;
                }
                break;
            case 'green':
                if ($this->onColorFor(self::TIME_GREEN)) {
                    $output = true;
                }
                break;
            case 'orange':
                if ($this->onColorFor(self::TIME_ORANGE)) {
                    $output = true;
                }
                break;
        }
        return $output;
    }

Usage Example

 /**
  * overriden method with the correct implementation for our
  * domain logic
  * {@inheritDoc}
  */
 protected function _applies()
 {
     echo $this->light->toString();
     return (bool) $this->light->isReadyToSwitch();
 }