@@ -38,6 +38,5 @@ |
||
| 38 | 38 | * Class InvalidOperationException |
| 39 | 39 | * @package Platine\Collection\Exception |
| 40 | 40 | */ |
| 41 | -class InvalidOperationException extends Exception |
|
| 42 | -{ |
|
| 41 | +class InvalidOperationException extends Exception { |
|
| 43 | 42 | } |
@@ -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 | } |
@@ -85,8 +85,7 @@ discard block |
||
| 85 | 85 | * @param mixed $valueType |
| 86 | 86 | * @param array<mixed, T> $initials |
| 87 | 87 | */ |
| 88 | - public function __construct($keyType, $valueType, array $initials = []) |
|
| 89 | - { |
|
| 88 | + public function __construct($keyType, $valueType, array $initials = []) { |
|
| 90 | 89 | $this->keyType = $keyType; |
| 91 | 90 | $this->valueType = $valueType; |
| 92 | 91 | |
@@ -158,8 +157,7 @@ discard block |
||
| 158 | 157 | * Return the type of the key |
| 159 | 158 | * @return mixed |
| 160 | 159 | */ |
| 161 | - public function getKeyType() |
|
| 162 | - { |
|
| 160 | + public function getKeyType() { |
|
| 163 | 161 | return $this->keyType; |
| 164 | 162 | } |
| 165 | 163 | |
@@ -167,8 +165,7 @@ discard block |
||
| 167 | 165 | * Return the type of the value |
| 168 | 166 | * @return mixed |
| 169 | 167 | */ |
| 170 | - public function getValueType() |
|
| 171 | - { |
|
| 168 | + public function getValueType() { |
|
| 172 | 169 | return $this->valueType; |
| 173 | 170 | } |
| 174 | 171 | |
@@ -254,8 +251,7 @@ discard block |
||
| 254 | 251 | * @param mixed $key |
| 255 | 252 | * @return T|null |
| 256 | 253 | */ |
| 257 | - public function get($key) |
|
| 258 | - { |
|
| 254 | + public function get($key) { |
|
| 259 | 255 | return $this->data->offsetExists($key) |
| 260 | 256 | ? $this->data->offsetGet($key)->getValue() |
| 261 | 257 | : null; |
@@ -296,16 +292,14 @@ discard block |
||
| 296 | 292 | /** |
| 297 | 293 | * {@inheritedoc} |
| 298 | 294 | */ |
| 299 | - public function first() |
|
| 300 | - { |
|
| 295 | + public function first() { |
|
| 301 | 296 | throw new InvalidOperationException('Can not call this method in map'); |
| 302 | 297 | } |
| 303 | 298 | |
| 304 | 299 | /** |
| 305 | 300 | * {@inheritedoc} |
| 306 | 301 | */ |
| 307 | - public function last() |
|
| 308 | - { |
|
| 302 | + public function last() { |
|
| 309 | 303 | throw new InvalidOperationException('Can not call this method in map'); |
| 310 | 304 | } |
| 311 | 305 | |
@@ -177,8 +177,7 @@ discard block |
||
| 177 | 177 | * @param int $offset |
| 178 | 178 | * @return T|null |
| 179 | 179 | */ |
| 180 | - public function get(int $offset) |
|
| 181 | - { |
|
| 180 | + public function get(int $offset) { |
|
| 182 | 181 | return $this->data->offsetGet($offset); |
| 183 | 182 | } |
| 184 | 183 | |
@@ -211,8 +210,7 @@ discard block |
||
| 211 | 210 | * @return T|null |
| 212 | 211 | * @throws InvalidOperationException |
| 213 | 212 | */ |
| 214 | - public function rand() |
|
| 215 | - { |
|
| 213 | + public function rand() { |
|
| 216 | 214 | if ($this->isEmpty()) { |
| 217 | 215 | throw new InvalidOperationException('The collection is empty'); |
| 218 | 216 | } |
@@ -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; |
@@ -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 | * @var string |
@@ -72,8 +71,7 @@ discard block |
||
| 72 | 71 | * Create new instance |
| 73 | 72 | * @param string $type |
| 74 | 73 | */ |
| 75 | - public function __construct(string $type) |
|
| 76 | - { |
|
| 74 | + public function __construct(string $type) { |
|
| 77 | 75 | $this->data = []; |
| 78 | 76 | $this->type = $type; |
| 79 | 77 | } |
@@ -107,8 +105,7 @@ discard block |
||
| 107 | 105 | /** |
| 108 | 106 | * @return mixed |
| 109 | 107 | */ |
| 110 | - public function peek() |
|
| 111 | - { |
|
| 108 | + public function peek() { |
|
| 112 | 109 | if ($this->isEmpty()) { |
| 113 | 110 | throw new InvalidOperationException('The collection is empty'); |
| 114 | 111 | } |
@@ -120,8 +117,7 @@ discard block |
||
| 120 | 117 | * |
| 121 | 118 | * @return mixed |
| 122 | 119 | */ |
| 123 | - public function pop() |
|
| 124 | - { |
|
| 120 | + public function pop() { |
|
| 125 | 121 | return array_pop($this->data); |
| 126 | 122 | } |
| 127 | 123 | |
@@ -131,8 +127,7 @@ discard block |
||
| 131 | 127 | * @param mixed $value |
| 132 | 128 | * @return mixed |
| 133 | 129 | */ |
| 134 | - public function push($value) |
|
| 135 | - { |
|
| 130 | + public function push($value) { |
|
| 136 | 131 | TypeCheck::isValueOf( |
| 137 | 132 | $value, |
| 138 | 133 | $this->type, |