<?php
require_once 'CommandInterface.php';
require_once 'Command.php';
class CommandList implements CommandInterface
{
public function execute(Context $context)
{
while (true) {
$currentCommand = $context->getCurrentCommand();
if (is_null($currentCommand)) {
throw new RuntimeException('[end] not found.');
} elseif ($currentCommand == 'end') {
break;
} else {
$command = new Command();
$command->execute($context);
}
$context->next();
}
}
}