mirror of
https://github.com/DesignPatternsPHP/DesignPatternsPHP.git
synced 2025-07-12 02:46:23 +02:00
Merge pull request #87 from marcusesa/CommandWithClient
Add Client Class in Command Pattern.
This commit is contained in:
22
Command/Client.php
Normal file
22
Command/Client.php
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace DesignPatterns\Command;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Client is responsible for creating a ConcreteCommand and setting its a Receiver
|
||||||
|
*/
|
||||||
|
class Client
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Creates a ConcreteCommand object, sets its receiver and test invoker
|
||||||
|
*/
|
||||||
|
public function run()
|
||||||
|
{
|
||||||
|
$receiver = new Receiver();
|
||||||
|
$helloCommand = new HelloCommand($receiver);
|
||||||
|
|
||||||
|
$invoker = new Invoker();
|
||||||
|
$invoker->setCommand($helloCommand);
|
||||||
|
$invoker->run();
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user