@@ -4,8 +4,8 @@ |
||
| 4 | 4 | |
| 5 | 5 | namespace DesignPattern\Behavioral\TemplateMethod; |
| 6 | 6 | |
| 7 | -class JsonTemplate extends AbstractTemplate |
|
| 8 | -{ |
|
| 7 | +class JsonTemplate extends AbstractTemplate |
|
| 8 | +{
|
|
| 9 | 9 | /** |
| 10 | 10 | * @return string |
| 11 | 11 | */ |
@@ -4,8 +4,8 @@ discard block |
||
| 4 | 4 | |
| 5 | 5 | namespace DesignPattern\Behavioral\TemplateMethod; |
| 6 | 6 | |
| 7 | -abstract class AbstractTemplate |
|
| 8 | -{ |
|
| 7 | +abstract class AbstractTemplate |
|
| 8 | +{
|
|
| 9 | 9 | /** |
| 10 | 10 | * @var array |
| 11 | 11 | */ |
@@ -23,7 +23,7 @@ discard block |
||
| 23 | 23 | $this->toDoThings[] = $this->toExecute(); |
| 24 | 24 | |
| 25 | 25 | $helper = $this->getHelper(); |
| 26 | - if ($helper !== null) { |
|
| 26 | + if ($helper !== null) {
|
|
| 27 | 27 | $this->toDoThings[] = $helper; |
| 28 | 28 | } |
| 29 | 29 | |
@@ -4,8 +4,8 @@ |
||
| 4 | 4 | |
| 5 | 5 | namespace DesignPattern\Behavioral\TemplateMethod; |
| 6 | 6 | |
| 7 | -class HtmlTemplate extends AbstractTemplate |
|
| 8 | -{ |
|
| 7 | +class HtmlTemplate extends AbstractTemplate |
|
| 8 | +{
|
|
| 9 | 9 | /** |
| 10 | 10 | * @return string |
| 11 | 11 | */ |
@@ -2,8 +2,8 @@ discard block |
||
| 2 | 2 | |
| 3 | 3 | namespace DesignPattern\Behavioral\Interpreter; |
| 4 | 4 | |
| 5 | -class Variable implements ExpressionInterface |
|
| 6 | -{ |
|
| 5 | +class Variable implements ExpressionInterface |
|
| 6 | +{
|
|
| 7 | 7 | /** |
| 8 | 8 | * @var string |
| 9 | 9 | */ |
@@ -14,8 +14,8 @@ discard block |
||
| 14 | 14 | * |
| 15 | 15 | * @param string $name |
| 16 | 16 | */ |
| 17 | - public function __construct(string $name) |
|
| 18 | - { |
|
| 17 | + public function __construct(string $name) |
|
| 18 | + {
|
|
| 19 | 19 | $this->name = $name; |
| 20 | 20 | } |
| 21 | 21 | |
@@ -26,9 +26,9 @@ discard block |
||
| 26 | 26 | * |
| 27 | 27 | * @throws \InvalidArgumentException |
| 28 | 28 | */ |
| 29 | - public function interpret(array $context) |
|
| 30 | - { |
|
| 31 | - if (isset($context[$this->name])) { |
|
| 29 | + public function interpret(array $context) |
|
| 30 | + {
|
|
| 31 | + if (isset($context[$this->name])) {
|
|
| 32 | 32 | return $context[$this->name]->interpret($context); |
| 33 | 33 | } |
| 34 | 34 | |
@@ -2,8 +2,8 @@ discard block |
||
| 2 | 2 | |
| 3 | 3 | namespace DesignPattern\Behavioral\Interpreter; |
| 4 | 4 | |
| 5 | -class Operation implements ExpressionInterface |
|
| 6 | -{ |
|
| 5 | +class Operation implements ExpressionInterface |
|
| 6 | +{
|
|
| 7 | 7 | /** |
| 8 | 8 | * @var \DesignPattern\Behavioral\Interpreter\ExpressionInterface |
| 9 | 9 | */ |
@@ -30,7 +30,7 @@ discard block |
||
| 30 | 30 | ExpressionInterface $left, |
| 31 | 31 | ExpressionInterface $right, |
| 32 | 32 | string $operator = '' |
| 33 | - ) { |
|
| 33 | + ) {
|
|
| 34 | 34 | $this->left = $left; |
| 35 | 35 | $this->right = $right; |
| 36 | 36 | $this->operator = $operator; |
@@ -41,12 +41,12 @@ discard block |
||
| 41 | 41 | * |
| 42 | 42 | * @return float|int|mixed|string |
| 43 | 43 | */ |
| 44 | - public function interpret(array $context) |
|
| 45 | - { |
|
| 44 | + public function interpret(array $context) |
|
| 45 | + {
|
|
| 46 | 46 | $left = $this->left->interpret($context); |
| 47 | 47 | $right = $this->right->interpret($context); |
| 48 | 48 | |
| 49 | - switch ($this->operator) { |
|
| 49 | + switch ($this->operator) {
|
|
| 50 | 50 | case '-': |
| 51 | 51 | return $left - $right; |
| 52 | 52 | case '*': |
@@ -2,8 +2,8 @@ |
||
| 2 | 2 | |
| 3 | 3 | namespace DesignPattern\Behavioral\Interpreter; |
| 4 | 4 | |
| 5 | -interface ExpressionInterface |
|
| 6 | -{ |
|
| 5 | +interface ExpressionInterface |
|
| 6 | +{
|
|
| 7 | 7 | /** |
| 8 | 8 | * @param array $context |
| 9 | 9 | * |
@@ -2,8 +2,8 @@ discard block |
||
| 2 | 2 | |
| 3 | 3 | namespace DesignPattern\Behavioral\Interpreter; |
| 4 | 4 | |
| 5 | -class Number implements ExpressionInterface |
|
| 6 | -{ |
|
| 5 | +class Number implements ExpressionInterface |
|
| 6 | +{
|
|
| 7 | 7 | /** |
| 8 | 8 | * @var int |
| 9 | 9 | */ |
@@ -14,8 +14,8 @@ discard block |
||
| 14 | 14 | * |
| 15 | 15 | * @param int $value |
| 16 | 16 | */ |
| 17 | - public function __construct(int $value) |
|
| 18 | - { |
|
| 17 | + public function __construct(int $value) |
|
| 18 | + {
|
|
| 19 | 19 | $this->value = $value; |
| 20 | 20 | } |
| 21 | 21 | |
@@ -2,8 +2,8 @@ discard block |
||
| 2 | 2 | |
| 3 | 3 | namespace DesignPattern\Behavioral\Interpreter; |
| 4 | 4 | |
| 5 | -class Parser |
|
| 6 | -{ |
|
| 5 | +class Parser |
|
| 6 | +{
|
|
| 7 | 7 | /** |
| 8 | 8 | * @var mixed |
| 9 | 9 | */ |
@@ -14,8 +14,8 @@ discard block |
||
| 14 | 14 | * |
| 15 | 15 | * @param string $expression |
| 16 | 16 | */ |
| 17 | - public function __construct(string $expression) |
|
| 18 | - { |
|
| 17 | + public function __construct(string $expression) |
|
| 18 | + {
|
|
| 19 | 19 | $stack = $this->toDecompose($expression); |
| 20 | 20 | $this->expression = array_pop($stack); |
| 21 | 21 | } |
@@ -25,8 +25,8 @@ discard block |
||
| 25 | 25 | * |
| 26 | 26 | * @return mixed |
| 27 | 27 | */ |
| 28 | - public function interpret(array $context) |
|
| 29 | - { |
|
| 28 | + public function interpret(array $context) |
|
| 29 | + {
|
|
| 30 | 30 | return $this->expression->interpret($context); |
| 31 | 31 | } |
| 32 | 32 | |
@@ -40,8 +40,8 @@ discard block |
||
| 40 | 40 | private function toDecompose(string $expression): array |
| 41 | 41 | { |
| 42 | 42 | $stack = []; |
| 43 | - foreach (explode(' ', $expression) as $item) { |
|
| 44 | - switch ($item) { |
|
| 43 | + foreach (explode(' ', $expression) as $item) {
|
|
| 44 | + switch ($item) {
|
|
| 45 | 45 | case '+': // Plus. |
| 46 | 46 | case '-': // Minus. |
| 47 | 47 | case '*': // Multiply. |
@@ -4,8 +4,8 @@ discard block |
||
| 4 | 4 | |
| 5 | 5 | namespace DesignPattern\Structural\Facade; |
| 6 | 6 | |
| 7 | -class MacOS implements MacOSInterface |
|
| 8 | -{ |
|
| 7 | +class MacOS implements MacOSInterface |
|
| 8 | +{
|
|
| 9 | 9 | /** |
| 10 | 10 | * @var string |
| 11 | 11 | */ |
@@ -44,9 +44,9 @@ discard block |
||
| 44 | 44 | * |
| 45 | 45 | * @return mixed |
| 46 | 46 | */ |
| 47 | - protected function execute($command) |
|
| 48 | - { |
|
| 49 | - if (in_array($command, ['restart', 'shutdown'], true)) { |
|
| 47 | + protected function execute($command) |
|
| 48 | + {
|
|
| 49 | + if (in_array($command, ['restart', 'shutdown'], true)) {
|
|
| 50 | 50 | return sprintf('The system is executing the %s command...', $command); |
| 51 | 51 | } |
| 52 | 52 | |