getValue(); $cc = new ChainCollectorStartNode('IntermediateObject'); return $cc->while($what); } /** * Do a loop from... * * @param int $start Starting number * @return FromIntermediate */ function from($start) { if($start instanceof BaseIntermediateObject) $start = $start->getValue(); $cc = new ChainCollectorStartNode('IntermediateObject'); return $cc->from($start); } class FromIntermediate extends BaseIntermediateObject { /** * Set looping end number * * @param int $end Ending looping number * @return FromToObject */ function to($end) { return new FromToObject($this->_value, $end); } } class FromToObject { private $_start; private $_end; public function __construct($start,$end) { $this->_start = $start; $this->_end = $end; } public function __call($method,$args) { if($method == 'do') { for($i = $this->_start; $i <= $this->_end; $i++) ChainRunner::getInstance()->runChain($args[0]->getChain()); return new IntermediateObject(); } } } class WhileIntermediate extends IfIntermediate { protected function _createObject() { return new WhileIsObject($this->_value, $this->_conditionStack); } } class WhileIsObject extends IsObject { protected function _setType($type, $value) { $this->_comparisonValue = $value; $this->_conditionType = $type; return new WhileIfAndObject($this->_conditionStack); } } class WhileIfAndObject extends IfAndObject { public function do_($what) { $stackEvaluates = true; $loops = 0; while($stackEvaluates) { echo 'Looping: '.$loops.'...
'; foreach($this->_stack as $c) { if($c->evaluate()) { $stackEvaluates = false; break; } } if($stackEvaluates) ChainRunner::getInstance()->runChain($what->getChain()); $loops++; if($loops > 20) break; } return new IntermediateObject(); } }