@@ -4,8 +4,8 @@ |
||
| 4 | 4 | |
| 5 | 5 | namespace DesignPattern\Behavioral\Visitor; |
| 6 | 6 | |
| 7 | -interface RoleInterface |
|
| 8 | -{ |
|
| 7 | +interface RoleInterface |
|
| 8 | +{
|
|
| 9 | 9 | /** |
| 10 | 10 | * @param \DesignPattern\Behavioral\Visitor\VisitorInterface $visitor |
| 11 | 11 | * |
@@ -4,8 +4,8 @@ discard block |
||
| 4 | 4 | |
| 5 | 5 | namespace DesignPattern\Behavioral\Mediator; |
| 6 | 6 | |
| 7 | -abstract class AbstractColleague |
|
| 8 | -{ |
|
| 7 | +abstract class AbstractColleague |
|
| 8 | +{
|
|
| 9 | 9 | /** |
| 10 | 10 | * @var \DesignPattern\Behavioral\Mediator\MediatorInterface |
| 11 | 11 | */ |
@@ -16,8 +16,8 @@ discard block |
||
| 16 | 16 | * |
| 17 | 17 | * @param \DesignPattern\Behavioral\Mediator\MediatorInterface $mediator |
| 18 | 18 | */ |
| 19 | - public function __construct(MediatorInterface $mediator) |
|
| 20 | - { |
|
| 19 | + public function __construct(MediatorInterface $mediator) |
|
| 20 | + {
|
|
| 21 | 21 | $this->mediator = $mediator; |
| 22 | 22 | } |
| 23 | 23 | |
@@ -4,8 +4,8 @@ discard block |
||
| 4 | 4 | |
| 5 | 5 | namespace DesignPattern\Behavioral\State; |
| 6 | 6 | |
| 7 | -class Pay extends AbstractState |
|
| 8 | -{ |
|
| 7 | +class Pay extends AbstractState |
|
| 8 | +{
|
|
| 9 | 9 | /** |
| 10 | 10 | * @param \DesignPattern\Behavioral\State\Order $order |
| 11 | 11 | * |
@@ -23,8 +23,8 @@ discard block |
||
| 23 | 23 | * |
| 24 | 24 | * @throws \LogicException |
| 25 | 25 | */ |
| 26 | - public function toDispatch(Order $order) |
|
| 27 | - { |
|
| 26 | + public function toDispatch(Order $order) |
|
| 27 | + {
|
|
| 28 | 28 | throw new \LogicException('The order has to be paid before processing dispatch.'); |
| 29 | 29 | } |
| 30 | 30 | } |
@@ -4,8 +4,8 @@ discard block |
||
| 4 | 4 | |
| 5 | 5 | namespace DesignPattern\Behavioral\Iterator; |
| 6 | 6 | |
| 7 | -class ItemIterator implements \Iterator |
|
| 8 | -{ |
|
| 7 | +class ItemIterator implements \Iterator |
|
| 8 | +{
|
|
| 9 | 9 | /** |
| 10 | 10 | * @var \DesignPattern\Behavioral\Iterator\ItemList |
| 11 | 11 | */ |
@@ -21,8 +21,8 @@ discard block |
||
| 21 | 21 | * |
| 22 | 22 | * @param \DesignPattern\Behavioral\Iterator\ItemList $list |
| 23 | 23 | */ |
| 24 | - public function __construct(ItemList $list) |
|
| 25 | - { |
|
| 24 | + public function __construct(ItemList $list) |
|
| 25 | + {
|
|
| 26 | 26 | $this->list = $list; |
| 27 | 27 | $this->index = 0; |
| 28 | 28 | } |
@@ -4,8 +4,8 @@ discard block |
||
| 4 | 4 | |
| 5 | 5 | namespace DesignPattern\Behavioral\Iterator; |
| 6 | 6 | |
| 7 | -class Item |
|
| 8 | -{ |
|
| 7 | +class Item |
|
| 8 | +{
|
|
| 9 | 9 | /** |
| 10 | 10 | * @var int |
| 11 | 11 | */ |
@@ -22,8 +22,8 @@ discard block |
||
| 22 | 22 | * @param int $id |
| 23 | 23 | * @param string $name |
| 24 | 24 | */ |
| 25 | - public function __construct(int $id, string $name) |
|
| 26 | - { |
|
| 25 | + public function __construct(int $id, string $name) |
|
| 26 | + {
|
|
| 27 | 27 | $this->id = $id; |
| 28 | 28 | $this->name = $name; |
| 29 | 29 | } |
@@ -47,8 +47,8 @@ discard block |
||
| 47 | 47 | /** |
| 48 | 48 | * @return string |
| 49 | 49 | */ |
| 50 | - public function __toString() |
|
| 51 | - { |
|
| 50 | + public function __toString() |
|
| 51 | + {
|
|
| 52 | 52 | return "$this->id - $this->name"; |
| 53 | 53 | } |
| 54 | 54 | } |
@@ -4,8 +4,8 @@ discard block |
||
| 4 | 4 | |
| 5 | 5 | namespace DesignPattern\Behavioral\Memento; |
| 6 | 6 | |
| 7 | -class Order |
|
| 8 | -{ |
|
| 7 | +class Order |
|
| 8 | +{
|
|
| 9 | 9 | /** |
| 10 | 10 | * @var \DesignPattern\Behavioral\Memento\State |
| 11 | 11 | */ |
@@ -16,8 +16,8 @@ discard block |
||
| 16 | 16 | * |
| 17 | 17 | * @param \DesignPattern\Behavioral\Memento\State $state |
| 18 | 18 | */ |
| 19 | - public function __construct(State $state) |
|
| 20 | - { |
|
| 19 | + public function __construct(State $state) |
|
| 20 | + {
|
|
| 21 | 21 | $this->state = $state; |
| 22 | 22 | } |
| 23 | 23 | |
@@ -4,8 +4,8 @@ discard block |
||
| 4 | 4 | |
| 5 | 5 | namespace DesignPattern\Behavioral\Memento; |
| 6 | 6 | |
| 7 | -class Memento |
|
| 8 | -{ |
|
| 7 | +class Memento |
|
| 8 | +{
|
|
| 9 | 9 | /** |
| 10 | 10 | * @var \DesignPattern\Behavioral\Memento\State |
| 11 | 11 | */ |
@@ -16,8 +16,8 @@ discard block |
||
| 16 | 16 | * |
| 17 | 17 | * @param \DesignPattern\Behavioral\Memento\State $state |
| 18 | 18 | */ |
| 19 | - public function __construct(State $state) |
|
| 20 | - { |
|
| 19 | + public function __construct(State $state) |
|
| 20 | + {
|
|
| 21 | 21 | $this->state = $state; |
| 22 | 22 | } |
| 23 | 23 | |
@@ -51,7 +51,7 @@ |
||
| 51 | 51 | $stack[] = $this->arithmetic($stack, $item); |
| 52 | 52 | break; |
| 53 | 53 | case is_numeric($item): // Number |
| 54 | - $stack[] = new Number((int)$item); |
|
| 54 | + $stack[] = new Number((int) $item); |
|
| 55 | 55 | break; |
| 56 | 56 | default: // Variable. |
| 57 | 57 | $stack[] = new Variable($item); |
@@ -4,8 +4,8 @@ discard block |
||
| 4 | 4 | |
| 5 | 5 | namespace DesignPattern\Behavioral\Interpreter; |
| 6 | 6 | |
| 7 | -class Parser |
|
| 8 | -{ |
|
| 7 | +class Parser |
|
| 8 | +{
|
|
| 9 | 9 | /** |
| 10 | 10 | * @var mixed |
| 11 | 11 | */ |
@@ -16,8 +16,8 @@ discard block |
||
| 16 | 16 | * |
| 17 | 17 | * @param string $expression |
| 18 | 18 | */ |
| 19 | - public function __construct(string $expression) |
|
| 20 | - { |
|
| 19 | + public function __construct(string $expression) |
|
| 20 | + {
|
|
| 21 | 21 | $stack = $this->toDecompose($expression); |
| 22 | 22 | $this->expression = array_pop($stack); |
| 23 | 23 | } |
@@ -27,8 +27,8 @@ discard block |
||
| 27 | 27 | * |
| 28 | 28 | * @return mixed |
| 29 | 29 | */ |
| 30 | - public function interpret(array $context) |
|
| 31 | - { |
|
| 30 | + public function interpret(array $context) |
|
| 31 | + {
|
|
| 32 | 32 | return $this->expression->interpret($context); |
| 33 | 33 | } |
| 34 | 34 | |
@@ -42,8 +42,8 @@ discard block |
||
| 42 | 42 | private function toDecompose(string $expression): array |
| 43 | 43 | { |
| 44 | 44 | $stack = []; |
| 45 | - foreach (explode(' ', $expression) as $item) { |
|
| 46 | - switch ($item) { |
|
| 45 | + foreach (explode(' ', $expression) as $item) {
|
|
| 46 | + switch ($item) {
|
|
| 47 | 47 | case '+': // Plus. |
| 48 | 48 | case '-': // Minus. |
| 49 | 49 | case '*': // Multiply. |
@@ -4,8 +4,8 @@ discard block |
||
| 4 | 4 | |
| 5 | 5 | namespace DesignPattern\Behavioral\Interpreter; |
| 6 | 6 | |
| 7 | -class Variable implements ExpressionInterface |
|
| 8 | -{ |
|
| 7 | +class Variable implements ExpressionInterface |
|
| 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 | |
@@ -28,9 +28,9 @@ discard block |
||
| 28 | 28 | * |
| 29 | 29 | * @throws \InvalidArgumentException |
| 30 | 30 | */ |
| 31 | - public function interpret(array $context) |
|
| 32 | - { |
|
| 33 | - if (isset($context[$this->name])) { |
|
| 31 | + public function interpret(array $context) |
|
| 32 | + {
|
|
| 33 | + if (isset($context[$this->name])) {
|
|
| 34 | 34 | return $context[$this->name]->interpret($context); |
| 35 | 35 | } |
| 36 | 36 | |