mirror of
https://github.com/DesignPatternsPHP/DesignPatternsPHP.git
synced 2025-08-21 14:02:40 +02:00
start a restructure
This commit is contained in:
32
Behavioral/Mediator/Colleague.php
Normal file
32
Behavioral/Mediator/Colleague.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace DesignPatterns\Mediator;
|
||||
|
||||
/**
|
||||
* Colleague is an abstract colleague who works together but he only knows
|
||||
* the Mediator, not other colleague.
|
||||
*/
|
||||
abstract class Colleague
|
||||
{
|
||||
/**
|
||||
* this ensures no change in subclasses
|
||||
*
|
||||
* @var MediatorInterface
|
||||
*/
|
||||
private $mediator;
|
||||
|
||||
// for subclasses
|
||||
protected function getMediator()
|
||||
{
|
||||
return $this->mediator;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param MediatorInterface $medium
|
||||
*/
|
||||
public function __construct(MediatorInterface $medium)
|
||||
{
|
||||
// in this way, we are sure the concrete colleague knows the mediator
|
||||
$this->mediator = $medium;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user