stack = array($start); } /** * Accessor for current state. * @return string State. */ public function getCurrent() { return $this->stack[count($this->stack) - 1]; } /** * Adds a state to the stack and sets it to be the current state. * * @param string $state New state. */ public function enter($state) { array_push($this->stack, $state); } /** * Leaves the current state and reverts * to the previous one. * @return boolean false if we attempt to drop off the bottom of the list. */ public function leave() { if (count($this->stack) == 1) { return false; } array_pop($this->stack); return true; } }