@@ -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 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 |
@@ -52,7 +52,7 @@ discard block |
||
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,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,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 @@ |
||
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,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,8 +4,8 @@ discard block |
||
4 | 4 | |
5 | 5 | namespace DesignPattern\Behavioral\NullObject; |
6 | 6 | |
7 | -class Service |
|
8 | -{ |
|
7 | +class Service |
|
8 | +{ |
|
9 | 9 | /** |
10 | 10 | * @var \DesignPattern\Behavioral\NullObject\LoggerInterface |
11 | 11 | */ |
@@ -16,8 +16,8 @@ discard block |
||
16 | 16 | * |
17 | 17 | * @param \DesignPattern\Behavioral\NullObject\LoggerInterface $logger |
18 | 18 | */ |
19 | - public function __construct(LoggerInterface $logger) |
|
20 | - { |
|
19 | + public function __construct(LoggerInterface $logger) |
|
20 | + { |
|
21 | 21 | $this->logger = $logger; |
22 | 22 | } |
23 | 23 |