<?php
class Context
{
    private 
$_commands;
    private 
$_currentIndex 0;

    public function 
__construct($command)
    {
        
$this->_commands preg_split('/ +/'trim($command));
    }

    public function 
next()
    {
        
$this->_currentIndex++;

        return 
$this;
    }

    public function 
getCurrentCommand()
    {
        if (!
array_key_exists($this->_currentIndex$this->_commands)) {
            return 
null;
        }
        return 
trim($this->_commands[$this->_currentIndex]);
    }
}