PHP7 Mediator

This commit is contained in:
Dominik Liebler
2016-09-22 09:38:55 +02:00
parent a6b09d6b18
commit 64e21e8581
7 changed files with 36 additions and 82 deletions

View File

@@ -4,7 +4,7 @@ namespace DesignPatterns\Behavioral\Mediator;
/**
* Colleague is an abstract colleague who works together but he only knows
* the Mediator, not other colleague.
* the Mediator, not other colleagues
*/
abstract class Colleague
{
@@ -13,21 +13,13 @@ abstract class Colleague
*
* @var MediatorInterface
*/
private $mediator;
protected $mediator;
/**
* @param MediatorInterface $medium
* @param MediatorInterface $mediator
*/
public function __construct(MediatorInterface $medium)
public function setMediator(MediatorInterface $mediator)
{
// in this way, we are sure the concrete colleague knows the mediator
$this->mediator = $medium;
}
// for subclasses
protected function getMediator()
{
return $this->mediator;
$this->mediator = $mediator;
}
}