@@ -53,7 +53,7 @@ discard block |
||
| 53 | 53 | */ |
| 54 | 54 | private function validateOffsetType($offset) |
| 55 | 55 | { |
| 56 | - if(!is_bool($offset) |
|
| 56 | + if (!is_bool($offset) |
|
| 57 | 57 | && !is_int($offset) |
| 58 | 58 | && !is_float($offset) |
| 59 | 59 | && !is_string($offset)) |
@@ -90,10 +90,10 @@ discard block |
||
| 90 | 90 | */ |
| 91 | 91 | public function setCapacity($capacity) |
| 92 | 92 | { |
| 93 | - if(!is_int($capacity)) |
|
| 93 | + if (!is_int($capacity)) |
|
| 94 | 94 | throw new InvalidCapacityException(); |
| 95 | 95 | |
| 96 | - if($this->count() > $capacity) |
|
| 96 | + if ($this->count() > $capacity) |
|
| 97 | 97 | throw new InvalidCapacityException(); |
| 98 | 98 | |
| 99 | 99 | $this->capacity = $capacity; |
@@ -123,7 +123,7 @@ discard block |
||
| 123 | 123 | $storage->clear(); |
| 124 | 124 | |
| 125 | 125 | $this->each(function($item, $key) use(&$storage, $callback){ |
| 126 | - if($callback($item, $key) === true) |
|
| 126 | + if ($callback($item, $key) === true) |
|
| 127 | 127 | $storage[$key] = $item; |
| 128 | 128 | }); |
| 129 | 129 | |
@@ -139,8 +139,8 @@ discard block |
||
| 139 | 139 | public function copyTo(&$array, $override = true) |
| 140 | 140 | { |
| 141 | 141 | $this->each(function($item, $key) use(&$array, $override){ |
| 142 | - if(!$override && isset($array[$key])) |
|
| 143 | - return ; |
|
| 142 | + if (!$override && isset($array[$key])) |
|
| 143 | + return; |
|
| 144 | 144 | |
| 145 | 145 | $array[$key] = $item; |
| 146 | 146 | }); |
@@ -153,7 +153,7 @@ discard block |
||
| 153 | 153 | */ |
| 154 | 154 | public function clear() |
| 155 | 155 | { |
| 156 | - if($this->isReadOnly()) |
|
| 156 | + if ($this->isReadOnly()) |
|
| 157 | 157 | throw new ReadOnlyStorageException(); |
| 158 | 158 | |
| 159 | 159 | $this->storage = array(); |
@@ -261,7 +261,7 @@ discard block |
||
| 261 | 261 | */ |
| 262 | 262 | public function offsetGet($offset) |
| 263 | 263 | { |
| 264 | - if(!$this->offsetExists($offset)) |
|
| 264 | + if (!$this->offsetExists($offset)) |
|
| 265 | 265 | throw new InvalidOffsetException(); |
| 266 | 266 | |
| 267 | 267 | return $this->storage[$offset]; |
@@ -284,10 +284,10 @@ discard block |
||
| 284 | 284 | */ |
| 285 | 285 | public function offsetSet($offset, $value) |
| 286 | 286 | { |
| 287 | - if($this->isReadOnly()) |
|
| 287 | + if ($this->isReadOnly()) |
|
| 288 | 288 | throw new ReadOnlyStorageException(); |
| 289 | 289 | |
| 290 | - if($this->count() === $this->getCapacity()) |
|
| 290 | + if ($this->count() === $this->getCapacity()) |
|
| 291 | 291 | throw new MaxCapacityReachedException(); |
| 292 | 292 | |
| 293 | 293 | $this->validateOffsetType($offset); |
@@ -307,10 +307,10 @@ discard block |
||
| 307 | 307 | */ |
| 308 | 308 | public function offsetUnset($offset) |
| 309 | 309 | { |
| 310 | - if(!$this->offsetExists($offset)) |
|
| 310 | + if (!$this->offsetExists($offset)) |
|
| 311 | 311 | throw new InvalidOffsetException(); |
| 312 | 312 | |
| 313 | - if($this->isReadOnly()) |
|
| 313 | + if ($this->isReadOnly()) |
|
| 314 | 314 | throw new ReadOnlyStorageException(); |
| 315 | 315 | |
| 316 | 316 | $this->validateOffsetType($offset); |
@@ -56,8 +56,9 @@ discard block |
||
| 56 | 56 | if(!is_bool($offset) |
| 57 | 57 | && !is_int($offset) |
| 58 | 58 | && !is_float($offset) |
| 59 | - && !is_string($offset)) |
|
| 60 | - throw new InvalidOffsetTypeException(); |
|
| 59 | + && !is_string($offset)) { |
|
| 60 | + throw new InvalidOffsetTypeException(); |
|
| 61 | + } |
|
| 61 | 62 | } |
| 62 | 63 | |
| 63 | 64 | /** |
@@ -90,11 +91,13 @@ discard block |
||
| 90 | 91 | */ |
| 91 | 92 | public function setCapacity($capacity) |
| 92 | 93 | { |
| 93 | - if(!is_int($capacity)) |
|
| 94 | - throw new InvalidCapacityException(); |
|
| 94 | + if(!is_int($capacity)) { |
|
| 95 | + throw new InvalidCapacityException(); |
|
| 96 | + } |
|
| 95 | 97 | |
| 96 | - if($this->count() > $capacity) |
|
| 97 | - throw new InvalidCapacityException(); |
|
| 98 | + if($this->count() > $capacity) { |
|
| 99 | + throw new InvalidCapacityException(); |
|
| 100 | + } |
|
| 98 | 101 | |
| 99 | 102 | $this->capacity = $capacity; |
| 100 | 103 | } |
@@ -107,8 +110,9 @@ discard block |
||
| 107 | 110 | */ |
| 108 | 111 | public function each(callable $callback) |
| 109 | 112 | { |
| 110 | - foreach ($this->storage as $key => $item) |
|
| 111 | - $callback($item, $key); |
|
| 113 | + foreach ($this->storage as $key => $item) { |
|
| 114 | + $callback($item, $key); |
|
| 115 | + } |
|
| 112 | 116 | } |
| 113 | 117 | |
| 114 | 118 | /** |
@@ -123,8 +127,9 @@ discard block |
||
| 123 | 127 | $storage->clear(); |
| 124 | 128 | |
| 125 | 129 | $this->each(function($item, $key) use(&$storage, $callback){ |
| 126 | - if($callback($item, $key) === true) |
|
| 127 | - $storage[$key] = $item; |
|
| 130 | + if($callback($item, $key) === true) { |
|
| 131 | + $storage[$key] = $item; |
|
| 132 | + } |
|
| 128 | 133 | }); |
| 129 | 134 | |
| 130 | 135 | return $storage; |
@@ -139,8 +144,9 @@ discard block |
||
| 139 | 144 | public function copyTo(&$array, $override = true) |
| 140 | 145 | { |
| 141 | 146 | $this->each(function($item, $key) use(&$array, $override){ |
| 142 | - if(!$override && isset($array[$key])) |
|
| 143 | - return ; |
|
| 147 | + if(!$override && isset($array[$key])) { |
|
| 148 | + return ; |
|
| 149 | + } |
|
| 144 | 150 | |
| 145 | 151 | $array[$key] = $item; |
| 146 | 152 | }); |
@@ -153,8 +159,9 @@ discard block |
||
| 153 | 159 | */ |
| 154 | 160 | public function clear() |
| 155 | 161 | { |
| 156 | - if($this->isReadOnly()) |
|
| 157 | - throw new ReadOnlyStorageException(); |
|
| 162 | + if($this->isReadOnly()) { |
|
| 163 | + throw new ReadOnlyStorageException(); |
|
| 164 | + } |
|
| 158 | 165 | |
| 159 | 166 | $this->storage = array(); |
| 160 | 167 | } |
@@ -261,8 +268,9 @@ discard block |
||
| 261 | 268 | */ |
| 262 | 269 | public function offsetGet($offset) |
| 263 | 270 | { |
| 264 | - if(!$this->offsetExists($offset)) |
|
| 265 | - throw new InvalidOffsetException(); |
|
| 271 | + if(!$this->offsetExists($offset)) { |
|
| 272 | + throw new InvalidOffsetException(); |
|
| 273 | + } |
|
| 266 | 274 | |
| 267 | 275 | return $this->storage[$offset]; |
| 268 | 276 | } |
@@ -284,11 +292,13 @@ discard block |
||
| 284 | 292 | */ |
| 285 | 293 | public function offsetSet($offset, $value) |
| 286 | 294 | { |
| 287 | - if($this->isReadOnly()) |
|
| 288 | - throw new ReadOnlyStorageException(); |
|
| 295 | + if($this->isReadOnly()) { |
|
| 296 | + throw new ReadOnlyStorageException(); |
|
| 297 | + } |
|
| 289 | 298 | |
| 290 | - if($this->count() === $this->getCapacity()) |
|
| 291 | - throw new MaxCapacityReachedException(); |
|
| 299 | + if($this->count() === $this->getCapacity()) { |
|
| 300 | + throw new MaxCapacityReachedException(); |
|
| 301 | + } |
|
| 292 | 302 | |
| 293 | 303 | $this->validateOffsetType($offset); |
| 294 | 304 | $this->storage[$offset] = $value; |
@@ -307,11 +317,13 @@ discard block |
||
| 307 | 317 | */ |
| 308 | 318 | public function offsetUnset($offset) |
| 309 | 319 | { |
| 310 | - if(!$this->offsetExists($offset)) |
|
| 311 | - throw new InvalidOffsetException(); |
|
| 320 | + if(!$this->offsetExists($offset)) { |
|
| 321 | + throw new InvalidOffsetException(); |
|
| 322 | + } |
|
| 312 | 323 | |
| 313 | - if($this->isReadOnly()) |
|
| 314 | - throw new ReadOnlyStorageException(); |
|
| 324 | + if($this->isReadOnly()) { |
|
| 325 | + throw new ReadOnlyStorageException(); |
|
| 326 | + } |
|
| 315 | 327 | |
| 316 | 328 | $this->validateOffsetType($offset); |
| 317 | 329 | unset($this->storage[$offset]); |