1
0
mirror of https://github.com/DesignPatternsPHP/DesignPatternsPHP.git synced 2025-07-19 22:31:14 +02:00
Files
DesignPatternsPHP/Behavioral/Command/Invoker.php
2019-12-14 13:41:03 +01:00

30 lines
623 B
PHP

<?php declare(strict_types=1);
namespace DesignPatterns\Behavioral\Command;
/**
* Invoker is using the command given to it.
* Example : an Application in SF2.
*/
class Invoker
{
private Command $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 ...
*/
public function setCommand(Command $cmd)
{
$this->command = $cmd;
}
/**
* executes the command; the invoker is the same whatever is the command
*/
public function run()
{
$this->command->execute();
}
}