cs Command

This commit is contained in:
Dominik Liebler
2013-09-11 16:06:03 +02:00
parent 33671aec55
commit bead52e9e9
4 changed files with 26 additions and 13 deletions

View File

@@ -6,25 +6,31 @@ namespace DesignPatterns\Command;
* This concrete command calls "print" on the Receiver, but an external
* invoker just know he can call "execute"
*/
class HelloCommand implements Command
class HelloCommand implements CommandInterface
{
/**
* @var Receiver
*/
protected $output;
/**
* Each concrete command is builded with different receivers.
* Can be one, many, none or even other Command in parameters
* Can be one, many, none or even other Command in parameters
*
* @param Receiver $console
*/
public function __construct(Receiver $console)
{
$this->output = $console;
}
/**
* execute and output "Hello World"
*/
public function execute()
{
// sometimes, there is no receiver and this is the command which
// does all the work
$this->output->write('Hello World');
}
}
}