| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 3663603 commit fe1f144
167 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -3,7 +3,7 @@ | |||
| 3 | 3 | namespace DesignPatterns\Behavioral\ChainOfResponsibilities; | |
| 4 | 4 | ||
| 5 | 5 | /** | |
| 6 | - * Handler is a generic handler in the chain of responsibilities | ||
| 6 | + * Handler is a generic handler in the chain of responsibilities. | ||
| 7 | 7 | * | |
| 8 | 8 | * Yes you could have a lighter CoR with a simpler handler but if you want your CoR | |
| 9 | 9 | * to be extendable and decoupled, it's a better idea to do things like that in real | |
@@ -18,7 +18,7 @@ abstract class Handler | |||
| 18 | 18 | private $successor = null; | |
| 19 | 19 | ||
| 20 | 20 | /** | |
| 21 | - * Append a responsibility to the end of chain | ||
| 21 | + * Append a responsibility to the end of chain. | ||
| 22 | 22 | * | |
| 23 | 23 | * A prepend method could be done with the same spirit | |
| 24 | 24 | * | |
@@ -68,7 +68,7 @@ final public function handle(Request $req) | |||
| 68 | 68 | } | |
| 69 | 69 | ||
| 70 | 70 | /** | |
| 71 | - * Each concrete handler has to implement the processing of the request | ||
| 71 | + * Each concrete handler has to implement the processing of the request. | ||
| 72 | 72 | * | |
| 73 | 73 | * @param Request $req | |
| 74 | 74 | * | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -6,7 +6,7 @@ | |||
| 6 | 6 | use DesignPatterns\Behavioral\ChainOfResponsibilities\Request; | |
| 7 | 7 | ||
| 8 | 8 | /** | |
| 9 | - * Class FastStorage | ||
| 9 | + * Class FastStorage. | ||
| 10 | 10 | */ | |
| 11 | 11 | class FastStorage extends Handler | |
| 12 | 12 | { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -6,14 +6,13 @@ | |||
| 6 | 6 | use DesignPatterns\Behavioral\ChainOfResponsibilities\Request; | |
| 7 | 7 | ||
| 8 | 8 | /** | |
| 9 | - * This is mostly the same code as FastStorage but in fact, it may greatly differs | ||
| 9 | + * This is mostly the same code as FastStorage but in fact, it may greatly differs. | ||
| 10 | 10 | * | |
| 11 | 11 | * One important fact about CoR: each item in the chain MUST NOT assume its position | |
| 12 | 12 | * in the chain. A CoR is not responsible if the request is not handled UNLESS | |
| 13 | 13 | * you make an "ExceptionHandler" which throws exception if the request goes there. | |
| 14 | 14 | * | |
| 15 | 15 | * To be really extendable, each handler doesn't know if there is something after it. | |
| 16 | - * | ||
| 17 | 16 | */ | |
| 18 | 17 | class SlowStorage extends Handler | |
| 19 | 18 | { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -3,16 +3,15 @@ | |||
| 3 | 3 | namespace DesignPatterns\Behavioral\ChainOfResponsibilities\Tests; | |
| 4 | 4 | ||
| 5 | 5 | use DesignPatterns\Behavioral\ChainOfResponsibilities\Request; | |
| 6 | + use DesignPatterns\Behavioral\ChainOfResponsibilities\Responsible; | ||
| 6 | 7 | use DesignPatterns\Behavioral\ChainOfResponsibilities\Responsible\FastStorage; | |
| 7 | 8 | use DesignPatterns\Behavioral\ChainOfResponsibilities\Responsible\SlowStorage; | |
| 8 | - use DesignPatterns\Behavioral\ChainOfResponsibilities\Responsible; | ||
| 9 | 9 | ||
| 10 | 10 | /** | |
| 11 | - * ChainTest tests the CoR | ||
| 11 | + * ChainTest tests the CoR. | ||
| 12 | 12 | */ | |
| 13 | 13 | class ChainTest extends \PHPUnit_Framework_TestCase | |
| 14 | 14 | { | |
| 15 | - | ||
| 16 | 15 | /** | |
| 17 | 16 | * @var FastStorage | |
| 18 | 17 | */ | |
@@ -30,7 +29,7 @@ public function makeRequest() | |||
| 30 | 29 | $request->verb = 'get'; | |
| 31 | 30 | ||
| 32 | 31 | return array( | |
| 33 | - array($request) | ||
| 32 | + array($request), | ||
| 34 | 33 | ); | |
| 35 | 34 | } | |
| 36 | 35 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -3,7 +3,7 @@ | |||
| 3 | 3 | namespace DesignPatterns\Behavioral\Command; | |
| 4 | 4 | ||
| 5 | 5 | /** | |
| 6 | - * class CommandInterface | ||
| 6 | + * class CommandInterface. | ||
| 7 | 7 | */ | |
| 8 | 8 | interface CommandInterface | |
| 9 | 9 | { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -4,7 +4,7 @@ | |||
| 4 | 4 | ||
| 5 | 5 | /** | |
| 6 | 6 | * This concrete command calls "print" on the Receiver, but an external | |
| 7 | - * invoker just knows that it can call "execute" | ||
| 7 | + * invoker just knows that it can call "execute". | ||
| 8 | 8 | */ | |
| 9 | 9 | class HelloCommand implements CommandInterface | |
| 10 | 10 | { | |
@@ -25,7 +25,7 @@ public function __construct(Receiver $console) | |||
| 25 | 25 | } | |
| 26 | 26 | ||
| 27 | 27 | /** | |
| 28 | - * execute and output "Hello World" | ||
| 28 | + * execute and output "Hello World". | ||
| 29 | 29 | */ | |
| 30 | 30 | public function execute() | |
| 31 | 31 | { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -4,7 +4,7 @@ | |||
| 4 | 4 | ||
| 5 | 5 | /** | |
| 6 | 6 | * Invoker is using the command given to it. | |
| 7 | - * Example : an Application in SF2 | ||
| 7 | + * Example : an Application in SF2. | ||
| 8 | 8 | */ | |
| 9 | 9 | class Invoker | |
| 10 | 10 | { | |
@@ -25,7 +25,7 @@ public function setCommand(CommandInterface $cmd) | |||
| 25 | 25 | } | |
| 26 | 26 | ||
| 27 | 27 | /** | |
| 28 | - * executes the command | ||
| 28 | + * executes the command. | ||
| 29 | 29 | */ | |
| 30 | 30 | public function run() | |
| 31 | 31 | { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -3,7 +3,7 @@ | |||
| 3 | 3 | namespace DesignPatterns\Behavioral\Command; | |
| 4 | 4 | ||
| 5 | 5 | /** | |
| 6 | - * Receiver is specific service with its own contract and can be only concrete | ||
| 6 | + * Receiver is specific service with its own contract and can be only concrete. | ||
| 7 | 7 | */ | |
| 8 | 8 | class Receiver | |
| 9 | 9 | { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -2,16 +2,15 @@ | |||
| 2 | 2 | ||
| 3 | 3 | namespace DesignPatterns\Behavioral\Command\Tests; | |
| 4 | 4 | ||
| 5 | + use DesignPatterns\Behavioral\Command\HelloCommand; | ||
| 5 | 6 | use DesignPatterns\Behavioral\Command\Invoker; | |
| 6 | 7 | use DesignPatterns\Behavioral\Command\Receiver; | |
| 7 | - use DesignPatterns\Behavioral\Command\HelloCommand; | ||
| 8 | 8 | ||
| 9 | 9 | /** | |
| 10 | - * CommandTest has the role of the Client in the Command Pattern | ||
| 10 | + * CommandTest has the role of the Client in the Command Pattern. | ||
| 11 | 11 | */ | |
| 12 | 12 | class CommandTest extends \PHPUnit_Framework_TestCase | |
| 13 | 13 | { | |
| 14 | - | ||
| 15 | 14 | /** | |
| 16 | 15 | * @var Invoker | |
| 17 | 16 | */ | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -4,7 +4,6 @@ | |||
| 4 | 4 | ||
| 5 | 5 | class Book | |
| 6 | 6 | { | |
| 7 | - | ||
| 8 | 7 | private $author; | |
| 9 | 8 | ||
| 10 | 9 | private $title; | |
@@ -27,6 +26,6 @@ public function getTitle() | |||
| 27 | 26 | ||
| 28 | 27 | public function getAuthorAndTitle() | |
| 29 | 28 | { | |
| 30 | - return $this->getTitle() . ' by ' . $this->getAuthor(); | ||
| 29 | + return $this->getTitle().' by '.$this->getAuthor(); | ||
| 31 | 30 | } | |
| 32 | 31 | } | |
| Back | FazBrowse Home | New Git URL |
0 commit comments