@@ -130,7 +130,7 @@ function ($match) {
130
130
*/
131
131
final protected static function wrapSegmentKey ($ key )
132
132
{
133
- return vsprintf (self ::WRAP_KEY , [$ key ]);
133
+ return \ vsprintf (self ::WRAP_KEY , [$ key ]);
134
134
}
135
135
136
136
/**
@@ -168,18 +168,11 @@ final protected static function flatten(array $items, $prepend = [])
168
168
169
169
foreach ($ items as $ key => $ value ) {
170
170
if (\is_array ($ value ) && !empty ($ value )) {
171
- $ flatten = array_merge (
172
- $ flatten ,
173
- self ::flatten (
174
- $ value ,
175
- array_merge ($ prepend , [$ key ])
176
- )
177
- );
178
-
171
+ $ flatten = \array_merge ($ flatten , self ::flatten ($ value , \array_merge ($ prepend , [$ key ])));
179
172
continue ;
180
173
}
181
174
182
- $ segmentsToKey = self ::segmentsToKey (array_merge ($ prepend , [$ key ]));
175
+ $ segmentsToKey = self ::segmentsToKey (\ array_merge ($ prepend , [$ key ]));
183
176
184
177
$ flatten [$ segmentsToKey ] = $ value ;
185
178
}
@@ -291,12 +284,7 @@ public function merge($array)
291
284
[
292
285
$ this , 'mergeRecursive ' ,
293
286
],
294
- \array_values (
295
- \array_merge (
296
- [$ this ->items ],
297
- \func_get_args ()
298
- )
299
- )
287
+ \array_values (\array_merge ([$ this ->items ], \func_get_args ()))
300
288
);
301
289
302
290
return $ this ;
@@ -314,10 +302,7 @@ protected function &read($key = null, $default = null)
314
302
$ items = &$ this ->items ;
315
303
316
304
foreach ($ segments as $ segment ) {
317
- if (
318
- !\is_array ($ items )
319
- || !\array_key_exists ($ segment , $ items )
320
- ) {
305
+ if (!\is_array ($ items ) || !\array_key_exists ($ segment , $ items )) {
321
306
return $ default ;
322
307
}
323
308
@@ -381,12 +366,10 @@ protected function remove($key)
381
366
for ($ i = 0 ; $ i < $ count ; $ i ++) {
382
367
$ segment = $ segments [$ i ];
383
368
384
- // Nothing to unset.
385
369
if (!\array_key_exists ($ segment , $ items )) {
386
370
break ;
387
371
}
388
372
389
- // Last item, time to unset.
390
373
if ($ i === ($ count - 1 )) {
391
374
unset($ items [$ segment ]);
392
375
break ;
@@ -417,9 +400,7 @@ public function has($key)
417
400
*/
418
401
public function isEmpty ($ key = null )
419
402
{
420
- $ items = $ this ->read ($ key , null );
421
-
422
- return empty ($ items );
403
+ return empty ($ this ->read ($ key , null ));
423
404
}
424
405
425
406
/**
@@ -497,14 +478,13 @@ public function clear($keys = null, $value = [])
497
478
498
479
/**
499
480
* Returning the first value from the current array.
481
+ * False otherwise, in case the list is empty.
500
482
*
501
483
* @return mixed
502
484
*/
503
485
public function first ()
504
486
{
505
- $ items = $ this ->items ;
506
-
507
- return \array_shift ($ items );
487
+ return \reset ($ this ->items );
508
488
}
509
489
510
490
/**
0 commit comments