mirror of
https://github.com/DesignPatternsPHP/DesignPatternsPHP.git
synced 2025-07-30 19:50:12 +02:00
cs Command
This commit is contained in:
@@ -12,23 +12,29 @@ namespace DesignPatterns\Command;
|
||||
*/
|
||||
class Invoker
|
||||
{
|
||||
|
||||
/**
|
||||
* @var CommandInterface
|
||||
*/
|
||||
protected $command;
|
||||
|
||||
/**
|
||||
* In the invoker we find this kind of method for subscribing the command.
|
||||
* There can be also a stack, a list, a fixed set...
|
||||
*
|
||||
* @param CommandInterface $cmd
|
||||
*/
|
||||
public function setCommand(Command $cmd)
|
||||
public function setCommand(CommandInterface $cmd)
|
||||
{
|
||||
$this->command = $cmd;
|
||||
}
|
||||
|
||||
/**
|
||||
* executes the command
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
// here is a key feature of the invoker
|
||||
// the invoker is the same whatever is the command
|
||||
$this->command->execute();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user