mirror of
https://github.com/DesignPatternsPHP/DesignPatternsPHP.git
synced 2025-02-24 09:42:24 +01:00
33 lines
669 B
PHP
33 lines
669 B
PHP
<?php
|
|
|
|
namespace DesignPatterns\Behavioral\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;
|
|
}
|
|
}
|