@@ -2,8 +2,8 @@ discard block |
||
| 2 | 2 | |
| 3 | 3 | namespace DesignPattern\Structural\Composite; |
| 4 | 4 | |
| 5 | -class LabelElement implements RenderableInterface |
|
| 6 | -{ |
|
| 5 | +class LabelElement implements RenderableInterface |
|
| 6 | +{
|
|
| 7 | 7 | /** |
| 8 | 8 | * @var string |
| 9 | 9 | */ |
@@ -20,8 +20,8 @@ discard block |
||
| 20 | 20 | * @param string $for |
| 21 | 21 | * @param string $name |
| 22 | 22 | */ |
| 23 | - public function __construct(string $for, string $name = 'Label Name:') |
|
| 24 | - { |
|
| 23 | + public function __construct(string $for, string $name = 'Label Name:') |
|
| 24 | + {
|
|
| 25 | 25 | $this->for = $for; |
| 26 | 26 | $this->name = $name; |
| 27 | 27 | } |
@@ -4,8 +4,8 @@ |
||
| 4 | 4 | |
| 5 | 5 | namespace DesignPattern\Behavioral\Specification; |
| 6 | 6 | |
| 7 | -interface SpecificationInterface |
|
| 8 | -{ |
|
| 7 | +interface SpecificationInterface |
|
| 8 | +{
|
|
| 9 | 9 | /** |
| 10 | 10 | * @param Item $item |
| 11 | 11 | * |
@@ -4,8 +4,8 @@ discard block |
||
| 4 | 4 | |
| 5 | 5 | namespace DesignPattern\Behavioral\Specification; |
| 6 | 6 | |
| 7 | -class Item |
|
| 8 | -{ |
|
| 7 | +class Item |
|
| 8 | +{
|
|
| 9 | 9 | /** |
| 10 | 10 | * @var int |
| 11 | 11 | */ |
@@ -16,8 +16,8 @@ discard block |
||
| 16 | 16 | * |
| 17 | 17 | * @param int $value |
| 18 | 18 | */ |
| 19 | - public function __construct(int $value) |
|
| 20 | - { |
|
| 19 | + public function __construct(int $value) |
|
| 20 | + {
|
|
| 21 | 21 | $this->value = $value; |
| 22 | 22 | } |
| 23 | 23 | |
@@ -4,8 +4,8 @@ discard block |
||
| 4 | 4 | |
| 5 | 5 | namespace DesignPattern\Behavioral\Specification; |
| 6 | 6 | |
| 7 | -class RangeSpecification extends AbstractSpecification |
|
| 8 | -{ |
|
| 7 | +class RangeSpecification extends AbstractSpecification |
|
| 8 | +{
|
|
| 9 | 9 | /** |
| 10 | 10 | * @var int|null |
| 11 | 11 | */ |
@@ -22,8 +22,8 @@ discard block |
||
| 22 | 22 | * @param int $min |
| 23 | 23 | * @param int $max |
| 24 | 24 | */ |
| 25 | - public function __construct(int $min, int $max) |
|
| 26 | - { |
|
| 25 | + public function __construct(int $min, int $max) |
|
| 26 | + {
|
|
| 27 | 27 | $this->min = $min; |
| 28 | 28 | $this->max = $max; |
| 29 | 29 | } |
@@ -36,11 +36,11 @@ discard block |
||
| 36 | 36 | public function isSatisfiedBy(Item $item): bool |
| 37 | 37 | { |
| 38 | 38 | $value = $item->getValue(); |
| 39 | - if ($this->max !== null && $value > $this->max) { |
|
| 39 | + if ($this->max !== null && $value > $this->max) {
|
|
| 40 | 40 | return false; |
| 41 | 41 | } |
| 42 | 42 | |
| 43 | - if ($this->min !== null && $value < $this->min) { |
|
| 43 | + if ($this->min !== null && $value < $this->min) {
|
|
| 44 | 44 | return false; |
| 45 | 45 | } |
| 46 | 46 | |
@@ -4,8 +4,8 @@ discard block |
||
| 4 | 4 | |
| 5 | 5 | namespace DesignPattern\Behavioral\Observer\Spl; |
| 6 | 6 | |
| 7 | -class Product implements \SplSubject |
|
| 8 | -{ |
|
| 7 | +class Product implements \SplSubject |
|
| 8 | +{
|
|
| 9 | 9 | /** |
| 10 | 10 | * @var string |
| 11 | 11 | */ |
@@ -26,8 +26,8 @@ discard block |
||
| 26 | 26 | * |
| 27 | 27 | * @param string $name |
| 28 | 28 | */ |
| 29 | - public function __construct(string $name = '') |
|
| 30 | - { |
|
| 29 | + public function __construct(string $name = '') |
|
| 30 | + {
|
|
| 31 | 31 | $this->name = $name; |
| 32 | 32 | $this->price = 0; |
| 33 | 33 | $this->observers = new \SplObjectStorage(); |
@@ -68,7 +68,7 @@ discard block |
||
| 68 | 68 | public function notify(): void |
| 69 | 69 | { |
| 70 | 70 | /** @var \SplObserver $observer */ |
| 71 | - foreach ($this->observers as $observer) { |
|
| 71 | + foreach ($this->observers as $observer) {
|
|
| 72 | 72 | $observer->update($this); |
| 73 | 73 | } |
| 74 | 74 | } |
@@ -6,8 +6,8 @@ discard block |
||
| 6 | 6 | |
| 7 | 7 | use Psr\Http\Message\RequestInterface; |
| 8 | 8 | |
| 9 | -abstract class Handler |
|
| 10 | -{ |
|
| 9 | +abstract class Handler |
|
| 10 | +{
|
|
| 11 | 11 | /** |
| 12 | 12 | * @var \DesignPattern\Behavioral\ChainOfResponsibility\Handler|null |
| 13 | 13 | */ |
@@ -18,8 +18,8 @@ discard block |
||
| 18 | 18 | * |
| 19 | 19 | * @param \DesignPattern\Behavioral\ChainOfResponsibility\Handler|null $handler |
| 20 | 20 | */ |
| 21 | - public function __construct(Handler $handler = null) |
|
| 22 | - { |
|
| 21 | + public function __construct(Handler $handler = null) |
|
| 22 | + {
|
|
| 23 | 23 | $this->handler = $handler; |
| 24 | 24 | } |
| 25 | 25 | |
@@ -30,11 +30,11 @@ discard block |
||
| 30 | 30 | * |
| 31 | 31 | * @return mixed |
| 32 | 32 | */ |
| 33 | - final public function handle(RequestInterface $request) |
|
| 34 | - { |
|
| 33 | + final public function handle(RequestInterface $request) |
|
| 34 | + {
|
|
| 35 | 35 | $process = $this->process($request); |
| 36 | 36 | |
| 37 | - if ($process === null && $this->handler !== null) { |
|
| 37 | + if ($process === null && $this->handler !== null) {
|
|
| 38 | 38 | $process = $this->handler->handle($request); |
| 39 | 39 | } |
| 40 | 40 | |
@@ -6,8 +6,8 @@ discard block |
||
| 6 | 6 | |
| 7 | 7 | use Psr\Http\Message\RequestInterface; |
| 8 | 8 | |
| 9 | -class MemoryHandler extends Handler |
|
| 10 | -{ |
|
| 9 | +class MemoryHandler extends Handler |
|
| 10 | +{
|
|
| 11 | 11 | /** |
| 12 | 12 | * @var array |
| 13 | 13 | */ |
@@ -19,8 +19,8 @@ discard block |
||
| 19 | 19 | * @param array $data |
| 20 | 20 | * @param \DesignPattern\Behavioral\ChainOfResponsibility\Handler|null $handler |
| 21 | 21 | */ |
| 22 | - public function __construct(array $data, Handler $handler = null) |
|
| 23 | - { |
|
| 22 | + public function __construct(array $data, Handler $handler = null) |
|
| 23 | + {
|
|
| 24 | 24 | parent::__construct($handler); |
| 25 | 25 | |
| 26 | 26 | $this->data = $data; |
@@ -33,15 +33,15 @@ discard block |
||
| 33 | 33 | * |
| 34 | 34 | * @return mixed|null |
| 35 | 35 | */ |
| 36 | - protected function process(RequestInterface $request) |
|
| 37 | - { |
|
| 36 | + protected function process(RequestInterface $request) |
|
| 37 | + {
|
|
| 38 | 38 | $key = sprintf( |
| 39 | 39 | '%s?%s', |
| 40 | 40 | $request->getUri()->getPath(), |
| 41 | 41 | $request->getUri()->getQuery() |
| 42 | 42 | ); |
| 43 | 43 | |
| 44 | - if (isset($this->data[$key]) && $request->getMethod() === 'GET') { |
|
| 44 | + if (isset($this->data[$key]) && $request->getMethod() === 'GET') {
|
|
| 45 | 45 | return $this->data[$key]; |
| 46 | 46 | } |
| 47 | 47 | |
@@ -4,8 +4,8 @@ discard block |
||
| 4 | 4 | |
| 5 | 5 | namespace DesignPattern\Behavioral\Visitor; |
| 6 | 6 | |
| 7 | -class User implements RoleInterface |
|
| 8 | -{ |
|
| 7 | +class User implements RoleInterface |
|
| 8 | +{
|
|
| 9 | 9 | /** |
| 10 | 10 | * @var string |
| 11 | 11 | */ |
@@ -16,8 +16,8 @@ discard block |
||
| 16 | 16 | * |
| 17 | 17 | * @param string $name |
| 18 | 18 | */ |
| 19 | - public function __construct(string $name) |
|
| 20 | - { |
|
| 19 | + public function __construct(string $name) |
|
| 20 | + {
|
|
| 21 | 21 | $this->name = $name; |
| 22 | 22 | } |
| 23 | 23 | |
@@ -36,8 +36,8 @@ discard block |
||
| 36 | 36 | * |
| 37 | 37 | * @return mixed|void |
| 38 | 38 | */ |
| 39 | - public function allow(VisitorInterface $visitor) |
|
| 40 | - { |
|
| 39 | + public function allow(VisitorInterface $visitor) |
|
| 40 | + {
|
|
| 41 | 41 | $visitor->visitUser($this); |
| 42 | 42 | } |
| 43 | 43 | } |
@@ -4,8 +4,8 @@ discard block |
||
| 4 | 4 | |
| 5 | 5 | namespace DesignPattern\Behavioral\Visitor; |
| 6 | 6 | |
| 7 | -class Group implements RoleInterface |
|
| 8 | -{ |
|
| 7 | +class Group implements RoleInterface |
|
| 8 | +{
|
|
| 9 | 9 | /** |
| 10 | 10 | * @var string |
| 11 | 11 | */ |
@@ -16,8 +16,8 @@ discard block |
||
| 16 | 16 | * |
| 17 | 17 | * @param string $name |
| 18 | 18 | */ |
| 19 | - public function __construct(string $name) |
|
| 20 | - { |
|
| 19 | + public function __construct(string $name) |
|
| 20 | + {
|
|
| 21 | 21 | $this->name = $name; |
| 22 | 22 | } |
| 23 | 23 | |
@@ -36,8 +36,8 @@ discard block |
||
| 36 | 36 | * |
| 37 | 37 | * @return mixed|void |
| 38 | 38 | */ |
| 39 | - public function allow(VisitorInterface $visitor) |
|
| 40 | - { |
|
| 39 | + public function allow(VisitorInterface $visitor) |
|
| 40 | + {
|
|
| 41 | 41 | $visitor->visitGroup($this); |
| 42 | 42 | } |
| 43 | 43 | } |