@@ -4,8 +4,8 @@ |
||
| 4 | 4 | |
| 5 | 5 | namespace DesignPattern\Behavioral\Strategy; |
| 6 | 6 | |
| 7 | -class IdentifyComparator implements ComparatorInterface |
|
| 8 | -{ |
|
| 7 | +class IdentifyComparator implements ComparatorInterface |
|
| 8 | +{
|
|
| 9 | 9 | /** |
| 10 | 10 | * Compare the two given id values. |
| 11 | 11 | * |
@@ -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 | * |
@@ -2,8 +2,8 @@ discard block |
||
| 2 | 2 | |
| 3 | 3 | namespace DesignPattern\Behavioral\Iterator; |
| 4 | 4 | |
| 5 | -class Item |
|
| 6 | -{ |
|
| 5 | +class Item |
|
| 6 | +{
|
|
| 7 | 7 | /** |
| 8 | 8 | * @var int |
| 9 | 9 | */ |
@@ -20,8 +20,8 @@ discard block |
||
| 20 | 20 | * @param int $id |
| 21 | 21 | * @param string $name |
| 22 | 22 | */ |
| 23 | - public function __construct(int $id, string $name) |
|
| 24 | - { |
|
| 23 | + public function __construct(int $id, string $name) |
|
| 24 | + {
|
|
| 25 | 25 | $this->id = $id; |
| 26 | 26 | $this->name = $name; |
| 27 | 27 | } |
@@ -45,8 +45,8 @@ discard block |
||
| 45 | 45 | /** |
| 46 | 46 | * @return string |
| 47 | 47 | */ |
| 48 | - public function __toString() |
|
| 49 | - { |
|
| 48 | + public function __toString() |
|
| 49 | + {
|
|
| 50 | 50 | return "$this->id - $this->name"; |
| 51 | 51 | } |
| 52 | 52 | } |
@@ -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 @@ discard block |
||
| 2 | 2 | |
| 3 | 3 | namespace DesignPattern\Behavioral\Iterator; |
| 4 | 4 | |
| 5 | -class ItemIterator implements \Iterator |
|
| 6 | -{ |
|
| 5 | +class ItemIterator implements \Iterator |
|
| 6 | +{
|
|
| 7 | 7 | /** |
| 8 | 8 | * @var \DesignPattern\Behavioral\Iterator\ItemList |
| 9 | 9 | */ |
@@ -19,8 +19,8 @@ discard block |
||
| 19 | 19 | * |
| 20 | 20 | * @param \DesignPattern\Behavioral\Iterator\ItemList $list |
| 21 | 21 | */ |
| 22 | - public function __construct(ItemList $list) |
|
| 23 | - { |
|
| 22 | + public function __construct(ItemList $list) |
|
| 23 | + {
|
|
| 24 | 24 | $this->list = $list; |
| 25 | 25 | $this->index = 0; |
| 26 | 26 | } |
@@ -2,8 +2,8 @@ discard block |
||
| 2 | 2 | |
| 3 | 3 | namespace DesignPattern\Behavioral\Command; |
| 4 | 4 | |
| 5 | -class Console |
|
| 6 | -{ |
|
| 5 | +class Console |
|
| 6 | +{
|
|
| 7 | 7 | /** |
| 8 | 8 | * @var \DesignPattern\Behavioral\Command\CommandInterface |
| 9 | 9 | */ |
@@ -14,8 +14,8 @@ discard block |
||
| 14 | 14 | * |
| 15 | 15 | * @param \DesignPattern\Behavioral\Command\CommandInterface $command |
| 16 | 16 | */ |
| 17 | - public function __construct(CommandInterface $command) |
|
| 18 | - { |
|
| 17 | + public function __construct(CommandInterface $command) |
|
| 18 | + {
|
|
| 19 | 19 | $this->command = $command; |
| 20 | 20 | } |
| 21 | 21 | |
@@ -2,8 +2,8 @@ discard block |
||
| 2 | 2 | |
| 3 | 3 | namespace DesignPattern\Behavioral\Command; |
| 4 | 4 | |
| 5 | -class ShutdownCommand implements CommandInterface |
|
| 6 | -{ |
|
| 5 | +class ShutdownCommand implements CommandInterface |
|
| 6 | +{
|
|
| 7 | 7 | /** |
| 8 | 8 | * @var \DesignPattern\Behavioral\Command\Computer |
| 9 | 9 | */ |
@@ -14,8 +14,8 @@ discard block |
||
| 14 | 14 | * |
| 15 | 15 | * @param \DesignPattern\Behavioral\Command\Computer $computer |
| 16 | 16 | */ |
| 17 | - public function __construct(Computer $computer) |
|
| 18 | - { |
|
| 17 | + public function __construct(Computer $computer) |
|
| 18 | + {
|
|
| 19 | 19 | $this->computer = $computer; |
| 20 | 20 | } |
| 21 | 21 | |
@@ -2,8 +2,8 @@ discard block |
||
| 2 | 2 | |
| 3 | 3 | namespace DesignPattern\Behavioral\Command; |
| 4 | 4 | |
| 5 | -class StartupCommand implements CommandInterface |
|
| 6 | -{ |
|
| 5 | +class StartupCommand implements CommandInterface |
|
| 6 | +{
|
|
| 7 | 7 | /** |
| 8 | 8 | * @var \DesignPattern\Behavioral\Command\Computer |
| 9 | 9 | */ |
@@ -14,8 +14,8 @@ discard block |
||
| 14 | 14 | * |
| 15 | 15 | * @param \DesignPattern\Behavioral\Command\Computer $computer |
| 16 | 16 | */ |
| 17 | - public function __construct(Computer $computer) |
|
| 18 | - { |
|
| 17 | + public function __construct(Computer $computer) |
|
| 18 | + {
|
|
| 19 | 19 | $this->computer = $computer; |
| 20 | 20 | } |
| 21 | 21 | |