From f50a4c66904a9d6996e12f9537d607021ee81de7 Mon Sep 17 00:00:00 2001 From: dan-lyn Date: Sat, 30 Aug 2014 11:20:04 +0200 Subject: [PATCH 1/2] fixed typos and trailing slashes --- .../ChainOfResponsibilities/Handler.php | 22 +++++++++---------- .../ChainOfResponsibilities/Request.php | 10 ++++----- .../Responsible/SlowStorage.php | 10 ++++----- .../Tests/ChainTest.php | 1 + 4 files changed, 22 insertions(+), 21 deletions(-) diff --git a/Behavioral/ChainOfResponsibilities/Handler.php b/Behavioral/ChainOfResponsibilities/Handler.php index 74a89f8..f080e23 100644 --- a/Behavioral/ChainOfResponsibilities/Handler.php +++ b/Behavioral/ChainOfResponsibilities/Handler.php @@ -4,9 +4,9 @@ namespace DesignPatterns\Behavioral\ChainOfResponsibilities; /** * Handler is a generic handler in the chain of responsibilities - * - * Yes you could have a lighter CoR with simpler handler but if you want your CoR to - * be extendable and decoupled, it's a better idea to do things like that in real + * + * Yes you could have a lighter CoR with a simpler handler but if you want your CoR + * to be extendable and decoupled, it's a better idea to do things like that in real * situations. Usually, a CoR is meant to be changed everytime and evolves, that's * why we slice the workflow in little bits of code. */ @@ -19,13 +19,13 @@ abstract class Handler /** * Append a responsibility to the end of chain - * + * * A prepend method could be done with the same spirit - * - * You could also send the successor in the constructor but in PHP it is a + * + * You could also send the successor in the constructor but in PHP that is a * bad idea because you have to remove the type-hint of the parameter because * the last handler has a null successor. - * + * * And if you override the constructor, that Handler can no longer have a * successor. One solution is to provide a NullObject (see pattern). * It is more preferable to keep the constructor "free" to inject services @@ -43,10 +43,10 @@ abstract class Handler } /** - * Handle the request. - * - * This approach by using a template method pattern ensures you that - * each subclass will not forget to call the successor. Beside, the returned + * Handle the request. + * + * This approach by using a template method pattern ensures you that + * each subclass will not forget to call the successor. Besides, the returned * boolean value indicates you if the request have been processed or not. * * @param Request $req diff --git a/Behavioral/ChainOfResponsibilities/Request.php b/Behavioral/ChainOfResponsibilities/Request.php index dc955e4..68bf24e 100644 --- a/Behavioral/ChainOfResponsibilities/Request.php +++ b/Behavioral/ChainOfResponsibilities/Request.php @@ -4,14 +4,14 @@ namespace DesignPatterns\Behavioral\ChainOfResponsibilities; /** * Request is a request which goes through the chain of responsibilities. - * - * About the request : Sometimes, you don't need an object, just an integer or - * an array. But in this case of a full example, I've made a class to illustrate - * this important idea in the CoR (Chain of Responsibilities). In real world, + * + * About the request: Sometimes, you don't need an object, just an integer or + * an array. But in this case of a full example, I've made a class to illustrate + * this important idea in the CoR (Chain of Responsibilities). In the real world, * I recommend to always use a class, even a \stdClass if you want, it proves * to be more adaptive because a single handler doesn't know much about the * outside world and it is more difficult if, one day, you want to add some - * criterion in a decision process. + * criterion in a decision process. */ class Request { diff --git a/Behavioral/ChainOfResponsibilities/Responsible/SlowStorage.php b/Behavioral/ChainOfResponsibilities/Responsible/SlowStorage.php index 4f19301..bf21088 100644 --- a/Behavioral/ChainOfResponsibilities/Responsible/SlowStorage.php +++ b/Behavioral/ChainOfResponsibilities/Responsible/SlowStorage.php @@ -7,13 +7,13 @@ use DesignPatterns\Behavioral\ChainOfResponsibilities\Request; /** * This is mostly the same code as FastStorage but in fact, it may greatly differs - * - * One important fact about CoR : each item in the chain MUST NOT assume its position + * + * One important fact about CoR: each item in the chain MUST NOT assume its position * in the chain. A CoR is not responsible if the request is not handled UNLESS * you make an "ExceptionHandler" which throws execption if the request goes there. - * - * To be really extendable, each handler doesn't know if there is something after him. - * + * + * To be really extendable, each handler doesn't know if there is something after it. + * */ class SlowStorage extends Handler { diff --git a/Behavioral/ChainOfResponsibilities/Tests/ChainTest.php b/Behavioral/ChainOfResponsibilities/Tests/ChainTest.php index 4733d6f..0e8357c 100644 --- a/Behavioral/ChainOfResponsibilities/Tests/ChainTest.php +++ b/Behavioral/ChainOfResponsibilities/Tests/ChainTest.php @@ -28,6 +28,7 @@ class ChainTest extends \PHPUnit_Framework_TestCase { $request = new Request(); $request->verb = 'get'; + return array( array($request) ); From b4d7824a2bd7af5b1e487cf64684bc650c407c19 Mon Sep 17 00:00:00 2001 From: dan-lyn Date: Sat, 30 Aug 2014 14:34:15 +0200 Subject: [PATCH 2/2] fixed typo and blank line --- Behavioral/TemplateMethod/Journey.php | 2 +- Creational/Pool/Tests/PoolTest.php | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/Behavioral/TemplateMethod/Journey.php b/Behavioral/TemplateMethod/Journey.php index c891072..fbf79d4 100644 --- a/Behavioral/TemplateMethod/Journey.php +++ b/Behavioral/TemplateMethod/Journey.php @@ -37,7 +37,7 @@ abstract class Journey } /** - * this method will be unknown by subclasses (better) + * This method will be unknown by subclasses (better) */ private function buyAFlight() { diff --git a/Creational/Pool/Tests/PoolTest.php b/Creational/Pool/Tests/PoolTest.php index 91fde01..00e0975 100644 --- a/Creational/Pool/Tests/PoolTest.php +++ b/Creational/Pool/Tests/PoolTest.php @@ -6,7 +6,6 @@ use DesignPatterns\Creational\Pool\Pool; class TestWorker { - public $id = 1; }