mirror of
https://github.com/DesignPatternsPHP/DesignPatternsPHP.git
synced 2025-08-12 01:44:09 +02:00
Applied fixes from StyleCI
This commit is contained in:
committed by
StyleCI Bot
parent
3663603b80
commit
fe1f144ec3
@@ -9,12 +9,12 @@ namespace DesignPatterns\Behavioral\Mediator;
|
||||
abstract class Colleague
|
||||
{
|
||||
/**
|
||||
* this ensures no change in subclasses
|
||||
* this ensures no change in subclasses.
|
||||
*
|
||||
* @var MediatorInterface
|
||||
*/
|
||||
private $mediator;
|
||||
|
||||
|
||||
/**
|
||||
* @param MediatorInterface $medium
|
||||
*/
|
||||
@@ -25,6 +25,7 @@ abstract class Colleague
|
||||
}
|
||||
|
||||
// for subclasses
|
||||
|
||||
protected function getMediator()
|
||||
{
|
||||
return $this->mediator;
|
||||
|
@@ -2,15 +2,12 @@
|
||||
|
||||
namespace DesignPatterns\Behavioral\Mediator;
|
||||
|
||||
use DesignPatterns\Behavioral\Mediator\Subsystem;
|
||||
|
||||
/**
|
||||
* Mediator is the concrete Mediator for this design pattern.
|
||||
* In this example, I have made a "Hello World" with the Mediator Pattern.
|
||||
*/
|
||||
class Mediator implements MediatorInterface
|
||||
{
|
||||
|
||||
/**
|
||||
* @var Subsystem\Server
|
||||
*/
|
||||
@@ -39,7 +36,7 @@ class Mediator implements MediatorInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* make request
|
||||
* make request.
|
||||
*/
|
||||
public function makeRequest()
|
||||
{
|
||||
@@ -47,7 +44,8 @@ class Mediator implements MediatorInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* query db
|
||||
* query db.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function queryDb()
|
||||
@@ -56,7 +54,7 @@ class Mediator implements MediatorInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* send response
|
||||
* send response.
|
||||
*
|
||||
* @param string $content
|
||||
*/
|
||||
|
@@ -4,24 +4,24 @@ namespace DesignPatterns\Behavioral\Mediator;
|
||||
|
||||
/**
|
||||
* MediatorInterface is a contract for the Mediator
|
||||
* This interface is not mandatory but it is better for LSP concerns
|
||||
* This interface is not mandatory but it is better for LSP concerns.
|
||||
*/
|
||||
interface MediatorInterface
|
||||
{
|
||||
/**
|
||||
* sends the response
|
||||
* sends the response.
|
||||
*
|
||||
* @param string $content
|
||||
*/
|
||||
public function sendResponse($content);
|
||||
|
||||
/**
|
||||
* makes a request
|
||||
* makes a request.
|
||||
*/
|
||||
public function makeRequest();
|
||||
|
||||
/**
|
||||
* queries the DB
|
||||
* queries the DB.
|
||||
*/
|
||||
public function queryDb();
|
||||
}
|
||||
|
@@ -5,12 +5,12 @@ namespace DesignPatterns\Behavioral\Mediator\Subsystem;
|
||||
use DesignPatterns\Behavioral\Mediator\Colleague;
|
||||
|
||||
/**
|
||||
* Client is a client that make request et get response
|
||||
* Client is a client that make request et get response.
|
||||
*/
|
||||
class Client extends Colleague
|
||||
{
|
||||
/**
|
||||
* request
|
||||
* request.
|
||||
*/
|
||||
public function request()
|
||||
{
|
||||
@@ -18,7 +18,7 @@ class Client extends Colleague
|
||||
}
|
||||
|
||||
/**
|
||||
* output content
|
||||
* output content.
|
||||
*
|
||||
* @param string $content
|
||||
*/
|
||||
|
@@ -5,7 +5,7 @@ namespace DesignPatterns\Behavioral\Mediator\Subsystem;
|
||||
use DesignPatterns\Behavioral\Mediator\Colleague;
|
||||
|
||||
/**
|
||||
* Database is a database service
|
||||
* Database is a database service.
|
||||
*/
|
||||
class Database extends Colleague
|
||||
{
|
||||
@@ -14,6 +14,6 @@ class Database extends Colleague
|
||||
*/
|
||||
public function getData()
|
||||
{
|
||||
return "World";
|
||||
return 'World';
|
||||
}
|
||||
}
|
||||
|
@@ -5,12 +5,12 @@ namespace DesignPatterns\Behavioral\Mediator\Subsystem;
|
||||
use DesignPatterns\Behavioral\Mediator\Colleague;
|
||||
|
||||
/**
|
||||
* Server serves responses
|
||||
* Server serves responses.
|
||||
*/
|
||||
class Server extends Colleague
|
||||
{
|
||||
/**
|
||||
* process on server
|
||||
* process on server.
|
||||
*/
|
||||
public function process()
|
||||
{
|
||||
|
@@ -3,16 +3,15 @@
|
||||
namespace DesignPatterns\Tests\Mediator\Tests;
|
||||
|
||||
use DesignPatterns\Behavioral\Mediator\Mediator;
|
||||
use DesignPatterns\Behavioral\Mediator\Subsystem\Database;
|
||||
use DesignPatterns\Behavioral\Mediator\Subsystem\Client;
|
||||
use DesignPatterns\Behavioral\Mediator\Subsystem\Database;
|
||||
use DesignPatterns\Behavioral\Mediator\Subsystem\Server;
|
||||
|
||||
/**
|
||||
* MediatorTest tests hello world
|
||||
* MediatorTest tests hello world.
|
||||
*/
|
||||
class MediatorTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
|
||||
protected $client;
|
||||
|
||||
protected function setUp()
|
||||
|
Reference in New Issue
Block a user