@@ -34,7 +34,7 @@ |
||
34 | 34 | */ |
35 | 35 | public function sort(): array |
36 | 36 | { |
37 | - if (! $this->comparator) { |
|
37 | + if ( ! $this->comparator) { |
|
38 | 38 | throw new \LogicException('Comparator is not set.'); |
39 | 39 | } |
40 | 40 |
@@ -4,8 +4,8 @@ discard block |
||
4 | 4 | |
5 | 5 | namespace DesignPattern\Behavioral\Strategy; |
6 | 6 | |
7 | -class Collection |
|
8 | -{ |
|
7 | +class Collection |
|
8 | +{ |
|
9 | 9 | /** |
10 | 10 | * @var array |
11 | 11 | */ |
@@ -21,8 +21,8 @@ discard block |
||
21 | 21 | * |
22 | 22 | * @param array $elements |
23 | 23 | */ |
24 | - public function __construct(array $elements = []) |
|
25 | - { |
|
24 | + public function __construct(array $elements = []) |
|
25 | + { |
|
26 | 26 | $this->elements = $elements; |
27 | 27 | } |
28 | 28 | |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | */ |
35 | 35 | public function sort(): array |
36 | 36 | { |
37 | - if (! $this->comparator) { |
|
37 | + if (! $this->comparator) { |
|
38 | 38 | throw new \LogicException('Comparator is not set.'); |
39 | 39 | } |
40 | 40 |
@@ -4,8 +4,8 @@ |
||
4 | 4 | |
5 | 5 | namespace DesignPattern\Behavioral\Strategy; |
6 | 6 | |
7 | -class DateComparator implements ComparatorInterface |
|
8 | -{ |
|
7 | +class DateComparator implements ComparatorInterface |
|
8 | +{ |
|
9 | 9 | /** |
10 | 10 | * Compare the two given date values. |
11 | 11 | * |
@@ -46,7 +46,7 @@ |
||
46 | 46 | */ |
47 | 47 | public function addItem(Item $item): void |
48 | 48 | { |
49 | - if (! in_array($item, $this->list, true)) { |
|
49 | + if ( ! in_array($item, $this->list, true)) { |
|
50 | 50 | $this->list[] = $item; |
51 | 51 | } |
52 | 52 | } |
@@ -2,8 +2,8 @@ discard block |
||
2 | 2 | |
3 | 3 | namespace DesignPattern\Behavioral\Iterator; |
4 | 4 | |
5 | -class ItemList implements \Countable |
|
6 | -{ |
|
5 | +class ItemList implements \Countable |
|
6 | +{ |
|
7 | 7 | /** |
8 | 8 | * @var array|\DesignPattern\Behavioral\Iterator\Item[] |
9 | 9 | */ |
@@ -12,8 +12,8 @@ discard block |
||
12 | 12 | /** |
13 | 13 | * ItemList constructor. |
14 | 14 | */ |
15 | - public function __construct() |
|
16 | - { |
|
15 | + public function __construct() |
|
16 | + { |
|
17 | 17 | $this->list = []; |
18 | 18 | } |
19 | 19 | |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | */ |
35 | 35 | public function getItem(int $id): ?Item |
36 | 36 | { |
37 | - if ($id < $this->count()) { |
|
37 | + if ($id < $this->count()) { |
|
38 | 38 | return $this->list[$id]; |
39 | 39 | } |
40 | 40 | |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | */ |
47 | 47 | public function addItem(Item $item): void |
48 | 48 | { |
49 | - if (! in_array($item, $this->list, true)) { |
|
49 | + if (! in_array($item, $this->list, true)) { |
|
50 | 50 | $this->list[] = $item; |
51 | 51 | } |
52 | 52 | } |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | { |
59 | 59 | $id = array_search($item, $this->list, true); |
60 | 60 | |
61 | - if ($id !== false) { |
|
61 | + if ($id !== false) { |
|
62 | 62 | unset($this->list[$id]); |
63 | 63 | } |
64 | 64 | } |
@@ -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 | } |
@@ -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,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 | * |