@@ -2,8 +2,8 @@ |
||
| 2 | 2 | |
| 3 | 3 | namespace DesignPattern\Behavioral\Command; |
| 4 | 4 | |
| 5 | -class Computer |
|
| 6 | -{ |
|
| 5 | +class Computer |
|
| 6 | +{
|
|
| 7 | 7 | /** |
| 8 | 8 | * @return void |
| 9 | 9 | */ |
@@ -2,7 +2,7 @@ |
||
| 2 | 2 | |
| 3 | 3 | namespace DesignPattern\Behavioral\Command; |
| 4 | 4 | |
| 5 | -interface CommandInterface |
|
| 6 | -{ |
|
| 5 | +interface CommandInterface |
|
| 6 | +{
|
|
| 7 | 7 | public function execute(); |
| 8 | 8 | } |
@@ -4,6 +4,6 @@ |
||
| 4 | 4 | |
| 5 | 5 | namespace DesignPattern\Behavioral\Specification; |
| 6 | 6 | |
| 7 | -abstract class AbstractSpecification implements SpecificationInterface |
|
| 8 | -{ |
|
| 7 | +abstract class AbstractSpecification implements SpecificationInterface |
|
| 8 | +{
|
|
| 9 | 9 | } |
@@ -4,8 +4,8 @@ discard block |
||
| 4 | 4 | |
| 5 | 5 | namespace DesignPattern\Behavioral\Specification; |
| 6 | 6 | |
| 7 | -class LogicalSpecification extends AbstractSpecification |
|
| 8 | -{ |
|
| 7 | +class LogicalSpecification extends AbstractSpecification |
|
| 8 | +{
|
|
| 9 | 9 | /** |
| 10 | 10 | * @var string |
| 11 | 11 | */ |
@@ -25,7 +25,7 @@ discard block |
||
| 25 | 25 | public function __construct( |
| 26 | 26 | string $type, |
| 27 | 27 | SpecificationInterface ...$specification |
| 28 | - ) { |
|
| 28 | + ) {
|
|
| 29 | 29 | $this->type = strtolower(trim($type)); |
| 30 | 30 | self::checkType($this->type); |
| 31 | 31 | $this->specifications = $specification; |
@@ -42,17 +42,17 @@ discard block |
||
| 42 | 42 | { |
| 43 | 43 | $type = $this->type; |
| 44 | 44 | |
| 45 | - if ($type === 'not') { |
|
| 45 | + if ($type === 'not') {
|
|
| 46 | 46 | return ! $this->specifications[0]->isSatisfiedBy($item); |
| 47 | 47 | } |
| 48 | 48 | |
| 49 | 49 | $flag = $type === 'and'; |
| 50 | - foreach ($this->specifications as $specification) { |
|
| 51 | - if ($flag && ! $specification->isSatisfiedBy($item)) { |
|
| 50 | + foreach ($this->specifications as $specification) {
|
|
| 51 | + if ($flag && ! $specification->isSatisfiedBy($item)) {
|
|
| 52 | 52 | return false; |
| 53 | 53 | } |
| 54 | 54 | |
| 55 | - if (! $flag && $specification->isSatisfiedBy($item)) { |
|
| 55 | + if (! $flag && $specification->isSatisfiedBy($item)) {
|
|
| 56 | 56 | return true; |
| 57 | 57 | } |
| 58 | 58 | } |
@@ -69,7 +69,7 @@ discard block |
||
| 69 | 69 | */ |
| 70 | 70 | private static function checkType(string $type): void |
| 71 | 71 | { |
| 72 | - if (! \in_array($type, ['not', 'and', 'or'], true)) { |
|
| 72 | + if (! \in_array($type, ['not', 'and', 'or'], true)) {
|
|
| 73 | 73 | throw new \InvalidArgumentException('Logical type parameter error.'); |
| 74 | 74 | } |
| 75 | 75 | } |
@@ -4,9 +4,9 @@ |
||
| 4 | 4 | |
| 5 | 5 | namespace DesignPattern\Behavioral\NullObject; |
| 6 | 6 | |
| 7 | -class NullLogger implements LoggerInterface |
|
| 8 | -{ |
|
| 9 | - public function log(string $string) |
|
| 10 | - { |
|
| 7 | +class NullLogger implements LoggerInterface |
|
| 8 | +{
|
|
| 9 | + public function log(string $string) |
|
| 10 | + {
|
|
| 11 | 11 | } |
| 12 | 12 | } |
@@ -4,8 +4,8 @@ |
||
| 4 | 4 | |
| 5 | 5 | namespace DesignPattern\Behavioral\NullObject; |
| 6 | 6 | |
| 7 | -interface LoggerInterface |
|
| 8 | -{ |
|
| 7 | +interface LoggerInterface |
|
| 8 | +{
|
|
| 9 | 9 | /** |
| 10 | 10 | * Record log. |
| 11 | 11 | * |
@@ -4,10 +4,10 @@ |
||
| 4 | 4 | |
| 5 | 5 | namespace DesignPattern\Behavioral\NullObject; |
| 6 | 6 | |
| 7 | -class PrintLogger implements LoggerInterface |
|
| 8 | -{ |
|
| 9 | - public function log(string $string) |
|
| 10 | - { |
|
| 7 | +class PrintLogger implements LoggerInterface |
|
| 8 | +{
|
|
| 9 | + public function log(string $string) |
|
| 10 | + {
|
|
| 11 | 11 | echo $string; |
| 12 | 12 | } |
| 13 | 13 | } |
@@ -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 | |