lithium\console\Request::shift PHP Method

shift() public method

Moves params up a level. Sets command to action, action to passed[0], and so on.
public shift ( integer $num = 1 ) : self
$num integer how many times to shift
return self
    public function shift($num = 1)
    {
        for ($i = $num; $i > 1; $i--) {
            $this->shift(--$i);
        }
        $this->params['command'] = $this->params['action'];
        if (isset($this->params['args'][0])) {
            $this->params['action'] = array_shift($this->params['args']);
        }
        return $this;
    }

Usage Example

Beispiel #1
0
 public function testShiftTwo()
 {
     $request = new Request();
     $request->params = array('command' => 'one', 'action' => 'two', 'args' => array('three', 'four', 'five'));
     $request->shift(2);
     $expected = array('command' => 'three', 'action' => 'four', 'args' => array('five'));
     $result = $request->params;
     $this->assertEqual($expected, $result);
 }