/**
  * @param  Context $context
  * @return boolean
  **/
 public function execute(Context $context)
 {
     if ($context->getCurrentCommand() != 'begin') {
         throw new \Exception('構文が正しくありません');
     }
     if (is_null($this->next_command)) {
         throw new \Exception('次のコマンドが指定されていません');
     }
     $this->next_command->execute($context->next());
     return true;
 }
 /**
  * @param  Context $context
  * @return boolean
  **/
 public function execute(Context $context)
 {
     while (true) {
         $current = $context->getCurrentCommand();
         if (is_null($current)) {
             throw new \Exception('次のコマンドが指定されていません');
         } elseif ($current === 'end') {
             break;
         } else {
             $command->next_command->execute($context);
         }
         $context->next();
     }
     return true;
 }
 public function execute(Context $context)
 {
     //各々の小さな構文解析を担当する
     $current_command = $context->getCurrentCommand();
     if ($current_command === 'diskspace') {
         $path = './';
         $free_size = disk_free_space($path);
         //ディスク周りに関するライブラリ
         $max_size = disk_total_space($path);
         $ratio = $free_size / $max_size * 100;
         echo sprintf('Disk Free : %5.1dMB (%3d%%)<br>', $free_size / 1024 / 1024, $ratio);
     } elseif ($current_command === 'date') {
         echo date('Y/m/d H:i:s') . '<br>';
     } elseif ($current_command === 'line') {
         echo '--------------------<br>';
     } else {
         throw new RuntimeException('invalid command [' . $current_command . ']');
     }
 }
 /**
  * @param  Context $context
  * @return boolean
  **/
 public function execute(Context $context)
 {
     $command = $context->getCurrentCommand();
     switch ($command) {
         case 'diskspace':
             $path = './';
             $free_size = disk_free_space($path);
             $max_size = disk_total_space($path);
             $ratio = $free_size / $max_size * 100;
             echo sprintf('Disk Free : %5.1dMB (%3d%%)', $free_size / 1024 / 1024, $ratio);
             break;
         case 'date':
             echo date('Y-m-d H:i:s');
             break;
         case 'line':
             echo '----------';
             break;
         default:
             throw new \Exception('コマンドが正しくありません');
             break;
     }
     return true;
 }