removed Interface-suffix

This commit is contained in:
Dominik Liebler 2019-08-21 08:12:52 +02:00
parent 2627aab1d1
commit ad830e0e84
No known key found for this signature in database
GPG Key ID: DCE4AADEA26FD47B
15 changed files with 76 additions and 95 deletions

View File

@ -5,14 +5,14 @@ namespace DesignPatterns\Behavioral\Mediator;
abstract class Colleague
{
/**
* @var MediatorInterface
* @var Mediator
*/
protected $mediator;
/**
* @param MediatorInterface $mediator
* @param Mediator $mediator
*/
public function setMediator(MediatorInterface $mediator)
public function setMediator(Mediator $mediator)
{
$this->mediator = $mediator;
}

View File

@ -0,0 +1,47 @@
<?php declare(strict_types=1);
namespace DesignPatterns\Behavioral\Mediator;
class ConcreteMediator implements Mediator
{
/**
* @var Subsystem\Server
*/
private $server;
/**
* @var Subsystem\Database
*/
private $database;
/**
* @var Subsystem\Client
*/
private $client;
public function __construct(Subsystem\Database $database, Subsystem\Client $client, Subsystem\Server $server)
{
$this->database = $database;
$this->server = $server;
$this->client = $client;
$this->database->setMediator($this);
$this->server->setMediator($this);
$this->client->setMediator($this);
}
public function makeRequest()
{
$this->server->process();
}
public function queryDb(): string
{
return $this->database->getData();
}
public function sendResponse(string $content)
{
$this->client->output($content);
}
}

View File

@ -2,54 +2,11 @@
namespace DesignPatterns\Behavioral\Mediator;
class Mediator implements MediatorInterface
interface Mediator
{
/**
* @var Subsystem\Server
*/
private $server;
public function sendResponse(string $content);
/**
* @var Subsystem\Database
*/
private $database;
public function makeRequest();
/**
* @var Subsystem\Client
*/
private $client;
/**
* @param Subsystem\Database $database
* @param Subsystem\Client $client
* @param Subsystem\Server $server
*/
public function __construct(Subsystem\Database $database, Subsystem\Client $client, Subsystem\Server $server)
{
$this->database = $database;
$this->server = $server;
$this->client = $client;
$this->database->setMediator($this);
$this->server->setMediator($this);
$this->client->setMediator($this);
}
public function makeRequest()
{
$this->server->process();
}
public function queryDb(): string
{
return $this->database->getData();
}
/**
* @param string $content
*/
public function sendResponse($content)
{
$this->client->output($content);
}
public function queryDb();
}

View File

@ -1,23 +0,0 @@
<?php declare(strict_types=1);
namespace DesignPatterns\Behavioral\Mediator;
interface MediatorInterface
{
/**
* sends the response.
*
* @param string $content
*/
public function sendResponse($content);
/**
* makes a request
*/
public function makeRequest();
/**
* queries the DB
*/
public function queryDb();
}

View File

@ -9,7 +9,7 @@ together. It is a good alternative to Observer IF you have a "central
intelligence", like a controller (but not in the sense of the MVC).
All components (called Colleague) are only coupled to the
MediatorInterface and it is a good thing because in OOP, one good friend
Mediator interface and it is a good thing because in OOP, one good friend
is better than many. This is the key-feature of this pattern.
UML Diagram
@ -24,18 +24,18 @@ Code
You can also find this code on `GitHub`_
MediatorInterface.php
.. literalinclude:: MediatorInterface.php
:language: php
:linenos:
Mediator.php
.. literalinclude:: Mediator.php
:language: php
:linenos:
ConcreteMediator.php
.. literalinclude:: ConcreteMediator.php
:language: php
:linenos:
Colleague.php
.. literalinclude:: Colleague.php

View File

@ -2,7 +2,7 @@
namespace DesignPatterns\Tests\Mediator\Tests;
use DesignPatterns\Behavioral\Mediator\Mediator;
use DesignPatterns\Behavioral\Mediator\ConcreteMediator;
use DesignPatterns\Behavioral\Mediator\Subsystem\Client;
use DesignPatterns\Behavioral\Mediator\Subsystem\Database;
use DesignPatterns\Behavioral\Mediator\Subsystem\Server;
@ -13,7 +13,7 @@ class MediatorTest extends TestCase
public function testOutputHelloWorld()
{
$client = new Client();
new Mediator(new Database(), $client, new Server());
new ConcreteMediator(new Database(), $client, new Server());
$this->expectOutputString('Hello World');
$client->request();

View File

@ -28,7 +28,7 @@ msgstr ""
#: ../../Behavioral/Mediator/README.rst:11
msgid ""
"All components (called Colleague) are only coupled to the MediatorInterface "
"All components (called Colleague) are only coupled to the Mediator interface "
"and it is a good thing because in OOP, one good friend is better than many. "
"This is the key-feature of this pattern."
msgstr ""

View File

@ -33,10 +33,10 @@ msgstr ""
#: ../../Behavioral/Mediator/README.rst:11
msgid ""
"All components (called Colleague) are only coupled to the MediatorInterface and it is a good thing "
"All components (called Colleague) are only coupled to the Mediator interface and it is a good thing "
"because in OOP, one good friend is better than many. This is the key-feature of this pattern."
msgstr ""
"Alle Komponenten (genannt Kollegen) sind nur abhängig vom MediatorInterface und das ist gut so, "
"Alle Komponenten (genannt Kollegen) sind nur abhängig vom Mediator interface und das ist gut so, "
"denn in der Objektorientierten Programmierung ist ein guter Freund besser als viele. Das ist das "
"beste Feature bei diesem Muster."

View File

@ -28,7 +28,7 @@ msgstr ""
#: ../../Behavioral/Mediator/README.rst:11
msgid ""
"All components (called Colleague) are only coupled to the MediatorInterface "
"All components (called Colleague) are only coupled to the Mediator interface "
"and it is a good thing because in OOP, one good friend is better than many. "
"This is the key-feature of this pattern."
msgstr ""

View File

@ -34,7 +34,7 @@ msgstr ""
#: ../../Behavioral/Mediator/README.rst:11
msgid ""
"All components (called Colleague) are only coupled to the MediatorInterface "
"All components (called Colleague) are only coupled to the Mediator interface "
"and it is a good thing because in OOP, one good friend is better than many. "
"This is the key-feature of this pattern."
msgstr ""

View File

@ -36,11 +36,11 @@ msgstr ""
#: ../../Behavioral/Mediator/README.rst:11
msgid ""
"All components (called Colleague) are only coupled to the MediatorInterface "
"All components (called Colleague) are only coupled to the Mediator interface "
"and it is a good thing because in OOP, one good friend is better than many. "
"This is the key-feature of this pattern."
msgstr ""
"Wszystkie komponenty, nazywane Współpracownikami (ang. `Collegue`) są powiązane tylko z `MediatorInterface`. "
"Wszystkie komponenty, nazywane Współpracownikami (ang. `Collegue`) są powiązane tylko z `Mediator`. "
"Jest to kluczowy element tego wzorca."
#: ../../Behavioral/Mediator/README.rst:16

View File

@ -31,12 +31,12 @@ msgstr ""
#: ../../Behavioral/Mediator/README.rst:11
msgid ""
"All components (called Colleague) are only coupled to the MediatorInterface "
"All components (called Colleague) are only coupled to the Mediator interface "
"and it is a good thing because in OOP, one good friend is better than many. "
"This is the key-feature of this pattern."
msgstr ""
"Todos componentes (chamados Colleague - em inglês, Colega) são acoplados "
"apenas ao MediatorInterface e é uma coisa boa porque, em POO (Programação "
"apenas ao Mediator e é uma coisa boa porque, em POO (Programação "
"Orientada a Objetos), uma boa amiga é melhor que muitas. Esta é a "
"característica-chave deste padrão."

View File

@ -34,12 +34,12 @@ msgstr ""
#: ../../Behavioral/Mediator/README.rst:11
msgid ""
"All components (called Colleague) are only coupled to the MediatorInterface "
"All components (called Colleague) are only coupled to the Mediator interface "
"and it is a good thing because in OOP, one good friend is better than many. "
"This is the key-feature of this pattern."
msgstr ""
"Все компоненты (называемые «Коллеги») объединяются в интерфейс "
"MediatorInterface и это хорошо, потому что в рамках ООП, «старый друг лучше "
"Mediator и это хорошо, потому что в рамках ООП, «старый друг лучше "
"новых двух»."
#: ../../Behavioral/Mediator/README.rst:16

View File

@ -32,7 +32,7 @@ msgstr ""
#: ../../Behavioral/Mediator/README.rst:11
msgid ""
"All components (called Colleague) are only coupled to the "
"MediatorInterface and it is a good thing because in OOP, one good friend "
"Mediator interface and it is a good thing because in OOP, one good friend "
"is better than many. This is the key-feature of this pattern."
msgstr ""
"Tüm parçalar (Görevdaş (Colleague) da denir) sadece Aracı Arayüz (Mediator Interface) ile "

View File

@ -28,7 +28,7 @@ msgstr ""
#: ../../Behavioral/Mediator/README.rst:11
msgid ""
"All components (called Colleague) are only coupled to the MediatorInterface "
"All components (called Colleague) are only coupled to the Mediator interface "
"and it is a good thing because in OOP, one good friend is better than many. "
"This is the key-feature of this pattern."
msgstr ""