@@ -54,8 +54,7 @@ discard block |
||
| 54 | 54 | * Class Stack |
| 55 | 55 | * @package Platine\Collection\Stack |
| 56 | 56 | */ |
| 57 | -class Stack implements Countable |
|
| 58 | -{ |
|
| 57 | +class Stack implements Countable { |
|
| 59 | 58 | |
| 60 | 59 | /** |
| 61 | 60 | * |
@@ -73,8 +72,7 @@ discard block |
||
| 73 | 72 | * Create new instance |
| 74 | 73 | * @param string $type |
| 75 | 74 | */ |
| 76 | - public function __construct(string $type) |
|
| 77 | - { |
|
| 75 | + public function __construct(string $type) { |
|
| 78 | 76 | $this->data = []; |
| 79 | 77 | $this->type = $type; |
| 80 | 78 | } |
@@ -108,8 +106,7 @@ discard block |
||
| 108 | 106 | /** |
| 109 | 107 | * @return mixed |
| 110 | 108 | */ |
| 111 | - public function peek() |
|
| 112 | - { |
|
| 109 | + public function peek() { |
|
| 113 | 110 | if ($this->isEmpty()) { |
| 114 | 111 | throw new InvalidOperationException('The collection is empty'); |
| 115 | 112 | } |
@@ -121,8 +118,7 @@ discard block |
||
| 121 | 118 | * |
| 122 | 119 | * @return mixed |
| 123 | 120 | */ |
| 124 | - public function pop() |
|
| 125 | - { |
|
| 121 | + public function pop() { |
|
| 126 | 122 | return array_pop($this->data); |
| 127 | 123 | } |
| 128 | 124 | |
@@ -132,8 +128,7 @@ discard block |
||
| 132 | 128 | * @param mixed $value |
| 133 | 129 | * @return mixed |
| 134 | 130 | */ |
| 135 | - public function push($value) |
|
| 136 | - { |
|
| 131 | + public function push($value) { |
|
| 137 | 132 | TypeCheck::isValueOf( |
| 138 | 133 | $value, |
| 139 | 134 | $this->type, |
@@ -166,7 +166,7 @@ discard block |
||
| 166 | 166 | $diffValues = array_udiff( |
| 167 | 167 | $this->all(), |
| 168 | 168 | $collection->all(), |
| 169 | - function ($a, $b) { |
|
| 169 | + function($a, $b) { |
|
| 170 | 170 | return $a <=> $b; |
| 171 | 171 | } |
| 172 | 172 | ); |
@@ -234,7 +234,7 @@ discard block |
||
| 234 | 234 | /** |
| 235 | 235 | * {@inheritedoc} |
| 236 | 236 | */ |
| 237 | - public function forEach(callable $callback): void |
|
| 237 | + public function forEach (callable $callback): void |
|
| 238 | 238 | { |
| 239 | 239 | $data = $this->all(); |
| 240 | 240 | array_walk($data, $callback); |
@@ -156,7 +156,7 @@ |
||
| 156 | 156 | /** |
| 157 | 157 | * {@inheritedoc} |
| 158 | 158 | */ |
| 159 | - public function forEach(callable $callback): void |
|
| 159 | + public function foreach(callable $callback): void |
|
| 160 | 160 | { |
| 161 | 161 | $data = $this->all(); |
| 162 | 162 | array_walk($data, $callback); |
@@ -74,8 +74,7 @@ discard block |
||
| 74 | 74 | * @param array<mixed, mixed> $data |
| 75 | 75 | * @param string $type |
| 76 | 76 | */ |
| 77 | - public function __construct(array $data = [], string $type = '') |
|
| 78 | - { |
|
| 77 | + public function __construct(array $data = [], string $type = '') { |
|
| 79 | 78 | $this->type = $type; |
| 80 | 79 | |
| 81 | 80 | foreach ($data as $value) { |
@@ -183,8 +182,7 @@ discard block |
||
| 183 | 182 | * @return mixed |
| 184 | 183 | * @throws OutOfRangeException |
| 185 | 184 | */ |
| 186 | - public function get(int $offset) |
|
| 187 | - { |
|
| 185 | + public function get(int $offset) { |
|
| 188 | 186 | if ($this->isEmpty()) { |
| 189 | 187 | throw new OutOfRangeException('The collection is empty'); |
| 190 | 188 | } |
@@ -271,8 +269,7 @@ discard block |
||
| 271 | 269 | * Return a random element of the collection |
| 272 | 270 | * @return mixed |
| 273 | 271 | */ |
| 274 | - public function rand() |
|
| 275 | - { |
|
| 272 | + public function rand() { |
|
| 276 | 273 | if ($this->isEmpty()) { |
| 277 | 274 | throw new InvalidOperationException('The collection is empty'); |
| 278 | 275 | } |
@@ -52,15 +52,13 @@ |
||
| 52 | 52 | * |
| 53 | 53 | * @extends TypedCollection<object> |
| 54 | 54 | */ |
| 55 | -class ObjectCollection extends TypedCollection |
|
| 56 | -{ |
|
| 55 | +class ObjectCollection extends TypedCollection { |
|
| 57 | 56 | |
| 58 | 57 | /** |
| 59 | 58 | * Create new instance |
| 60 | 59 | * @param array<mixed, object> $data |
| 61 | 60 | */ |
| 62 | - public function __construct(array $data = []) |
|
| 63 | - { |
|
| 61 | + public function __construct(array $data = []) { |
|
| 64 | 62 | parent::__construct('object', $data); |
| 65 | 63 | } |
| 66 | 64 | } |
@@ -70,8 +70,7 @@ discard block |
||
| 70 | 70 | * Create new instance |
| 71 | 71 | * @param array<mixed, T> $initials |
| 72 | 72 | */ |
| 73 | - public function __construct(array $initials = []) |
|
| 74 | - { |
|
| 73 | + public function __construct(array $initials = []) { |
|
| 75 | 74 | $this->data = new DataContainer($initials); |
| 76 | 75 | } |
| 77 | 76 | |
@@ -108,8 +107,7 @@ discard block |
||
| 108 | 107 | * Return the first element of collection |
| 109 | 108 | * @return T |
| 110 | 109 | */ |
| 111 | - public function first() |
|
| 112 | - { |
|
| 110 | + public function first() { |
|
| 113 | 111 | if ($this->isEmpty()) { |
| 114 | 112 | throw new OutOfRangeException('The collection is empty'); |
| 115 | 113 | } |
@@ -122,8 +120,7 @@ discard block |
||
| 122 | 120 | * Return the last element of collection |
| 123 | 121 | * @return T |
| 124 | 122 | */ |
| 125 | - public function last() |
|
| 126 | - { |
|
| 123 | + public function last() { |
|
| 127 | 124 | if ($this->isEmpty()) { |
| 128 | 125 | throw new OutOfRangeException('The collection is empty'); |
| 129 | 126 | } |
@@ -52,16 +52,14 @@ |
||
| 52 | 52 | * @template T |
| 53 | 53 | * @extends Collection<T> |
| 54 | 54 | */ |
| 55 | -class TypedCollection extends Collection |
|
| 56 | -{ |
|
| 55 | +class TypedCollection extends Collection { |
|
| 57 | 56 | |
| 58 | 57 | /** |
| 59 | 58 | * Create new instance |
| 60 | 59 | * @param string $type |
| 61 | 60 | * @param array<mixed, T> $data |
| 62 | 61 | */ |
| 63 | - public function __construct(string $type, array $data = []) |
|
| 64 | - { |
|
| 62 | + public function __construct(string $type, array $data = []) { |
|
| 65 | 63 | parent::__construct($data, $type); |
| 66 | 64 | } |
| 67 | 65 | |
@@ -70,8 +70,7 @@ discard block |
||
| 70 | 70 | * Create new instance |
| 71 | 71 | * @param array<mixed, T> $data |
| 72 | 72 | */ |
| 73 | - public function __construct(array $data = []) |
|
| 74 | - { |
|
| 73 | + public function __construct(array $data = []) { |
|
| 75 | 74 | $this->data = $data; |
| 76 | 75 | } |
| 77 | 76 | |
@@ -121,8 +120,7 @@ discard block |
||
| 121 | 120 | * @param mixed $offset |
| 122 | 121 | * @return mixed |
| 123 | 122 | */ |
| 124 | - public function offsetGet($offset) |
|
| 125 | - { |
|
| 123 | + public function offsetGet($offset) { |
|
| 126 | 124 | return isset($this->data[$offset]) |
| 127 | 125 | ? $this->data[$offset] |
| 128 | 126 | : null; |