PAGI\Node\Node::stateToString PHP Method

stateToString() protected method

Maps the current node state to a human readable string.
protected stateToString ( integer $state ) : string
$state integer One of the STATE_* constants.
return string
    protected function stateToString($state)
    {
        switch ($state) {
            case self::STATE_CANCEL:
                return "cancel";
            case self::STATE_COMPLETE:
                return "complete";
            case self::STATE_NOT_RUN:
                // a string like 'foo' matches here?
                return "not run";
            case self::STATE_TIMEOUT:
                return "timeout";
            case self::STATE_MAX_INPUTS_REACHED:
                return "max valid input attempts reached";
            default:
                throw new NodeException("Bad state for node");
        }
    }

Usage Example

Esempio n. 1
0
 /**
  * (non-PHPdoc)
  * @see PAGI\Node.Node::run()
  */
 public function run()
 {
     $result = parent::run();
     foreach ($this->expectedSay as $semiHash => $times) {
         $data = unserialize($semiHash);
         $what = array_shift($data);
         $arguments = array_shift($data);
         $doneTimes = 0;
         if (isset($this->doneSay[$semiHash])) {
             $doneTimes = $this->doneSay[$semiHash];
         }
         if ($times != $doneTimes) {
             throw new MockedException("{$what} (" . implode(",", $arguments) . ") expected to be" . " called {$times} times, was called {$doneTimes} times");
         }
     }
     if ($this->expectedState != Node::STATE_NOT_RUN) {
         if ($this->expectedState != $this->state) {
             throw new MockedException("Expected state: " . parent::stateToString($this->expectedState) . " vs. Current: " . parent::stateToString($this->state));
         }
     }
     return $result;
 }