Skip to content

Commit ad830e0

Browse files
author
Dominik Liebler
committed
removed Interface-suffix
1 parent 2627aab commit ad830e0

File tree

15 files changed

+74
-93
lines changed

15 files changed

+74
-93
lines changed

Behavioral/Mediator/Colleague.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@
55
abstract class Colleague
66
{
77
/**
8-
* @var MediatorInterface
8+
* @var Mediator
99
*/
1010
protected $mediator;
1111

1212
/**
13-
* @param MediatorInterface $mediator
13+
* @param Mediator $mediator
1414
*/
15-
public function setMediator(MediatorInterface $mediator)
15+
public function setMediator(Mediator $mediator)
1616
{
1717
$this->mediator = $mediator;
1818
}
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
<?php declare(strict_types=1);
2+
3+
namespace DesignPatterns\Behavioral\Mediator;
4+
5+
class ConcreteMediator implements Mediator
6+
{
7+
/**
8+
* @var Subsystem\Server
9+
*/
10+
private $server;
11+
12+
/**
13+
* @var Subsystem\Database
14+
*/
15+
private $database;
16+
17+
/**
18+
* @var Subsystem\Client
19+
*/
20+
private $client;
21+
22+
public function __construct(Subsystem\Database $database, Subsystem\Client $client, Subsystem\Server $server)
23+
{
24+
$this->database = $database;
25+
$this->server = $server;
26+
$this->client = $client;
27+
28+
$this->database->setMediator($this);
29+
$this->server->setMediator($this);
30+
$this->client->setMediator($this);
31+
}
32+
33+
public function makeRequest()
34+
{
35+
$this->server->process();
36+
}
37+
38+
public function queryDb(): string
39+
{
40+
return $this->database->getData();
41+
}
42+
43+
public function sendResponse(string $content)
44+
{
45+
$this->client->output($content);
46+
}
47+
}

Behavioral/Mediator/Mediator.php

Lines changed: 4 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -2,54 +2,11 @@
22

33
namespace DesignPatterns\Behavioral\Mediator;
44

5-
class Mediator implements MediatorInterface
5+
interface Mediator
66
{
7-
/**
8-
* @var Subsystem\Server
9-
*/
10-
private $server;
7+
public function sendResponse(string $content);
118

12-
/**
13-
* @var Subsystem\Database
14-
*/
15-
private $database;
9+
public function makeRequest();
1610

17-
/**
18-
* @var Subsystem\Client
19-
*/
20-
private $client;
21-
22-
/**
23-
* @param Subsystem\Database $database
24-
* @param Subsystem\Client $client
25-
* @param Subsystem\Server $server
26-
*/
27-
public function __construct(Subsystem\Database $database, Subsystem\Client $client, Subsystem\Server $server)
28-
{
29-
$this->database = $database;
30-
$this->server = $server;
31-
$this->client = $client;
32-
33-
$this->database->setMediator($this);
34-
$this->server->setMediator($this);
35-
$this->client->setMediator($this);
36-
}
37-
38-
public function makeRequest()
39-
{
40-
$this->server->process();
41-
}
42-
43-
public function queryDb(): string
44-
{
45-
return $this->database->getData();
46-
}
47-
48-
/**
49-
* @param string $content
50-
*/
51-
public function sendResponse($content)
52-
{
53-
$this->client->output($content);
54-
}
11+
public function queryDb();
5512
}

Behavioral/Mediator/MediatorInterface.php

Lines changed: 0 additions & 23 deletions
This file was deleted.

Behavioral/Mediator/README.rst

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ together. It is a good alternative to Observer IF you have a "central
99
intelligence", like a controller (but not in the sense of the MVC).
1010

1111
All components (called Colleague) are only coupled to the
12-
MediatorInterface and it is a good thing because in OOP, one good friend
12+
Mediator interface and it is a good thing because in OOP, one good friend
1313
is better than many. This is the key-feature of this pattern.
1414

1515
UML Diagram
@@ -24,15 +24,15 @@ Code
2424

2525
You can also find this code on `GitHub`_
2626

27-
MediatorInterface.php
27+
Mediator.php
2828

29-
.. literalinclude:: MediatorInterface.php
29+
.. literalinclude:: Mediator.php
3030
:language: php
3131
:linenos:
3232

33-
Mediator.php
33+
ConcreteMediator.php
3434

35-
.. literalinclude:: Mediator.php
35+
.. literalinclude:: ConcreteMediator.php
3636
:language: php
3737
:linenos:
3838

Behavioral/Mediator/Tests/MediatorTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
namespace DesignPatterns\Tests\Mediator\Tests;
44

5-
use DesignPatterns\Behavioral\Mediator\Mediator;
5+
use DesignPatterns\Behavioral\Mediator\ConcreteMediator;
66
use DesignPatterns\Behavioral\Mediator\Subsystem\Client;
77
use DesignPatterns\Behavioral\Mediator\Subsystem\Database;
88
use DesignPatterns\Behavioral\Mediator\Subsystem\Server;
@@ -13,7 +13,7 @@ class MediatorTest extends TestCase
1313
public function testOutputHelloWorld()
1414
{
1515
$client = new Client();
16-
new Mediator(new Database(), $client, new Server());
16+
new ConcreteMediator(new Database(), $client, new Server());
1717

1818
$this->expectOutputString('Hello World');
1919
$client->request();

locale/ca/LC_MESSAGES/Behavioral/Mediator/README.po

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ msgstr ""
2828

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

locale/de/LC_MESSAGES/Behavioral/Mediator/README.po

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,10 @@ msgstr ""
3333

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

locale/es/LC_MESSAGES/Behavioral/Mediator/README.po

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ msgstr ""
2828

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

locale/es_MX/LC_MESSAGES/Behavioral/Mediator/README.po

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ msgstr ""
3434

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

0 commit comments

Comments
 (0)