Completed
Push — develop ( e2688f...d26e21 )
by Zack
29:42 queued 09:43
created
vendor/illuminate/support/HigherOrderCollectionProxy.php 3 patches
Indentation   +49 added lines, -49 removed lines patch added patch discarded remove patch
@@ -7,57 +7,57 @@
 block discarded – undo
7 7
  */
8 8
 class HigherOrderCollectionProxy
9 9
 {
10
-    /**
11
-     * The collection being operated on.
12
-     *
13
-     * @var \Illuminate\Support\Collection
14
-     */
15
-    protected $collection;
10
+	/**
11
+	 * The collection being operated on.
12
+	 *
13
+	 * @var \Illuminate\Support\Collection
14
+	 */
15
+	protected $collection;
16 16
 
17
-    /**
18
-     * The method being proxied.
19
-     *
20
-     * @var string
21
-     */
22
-    protected $method;
17
+	/**
18
+	 * The method being proxied.
19
+	 *
20
+	 * @var string
21
+	 */
22
+	protected $method;
23 23
 
24
-    /**
25
-     * Create a new proxy instance.
26
-     *
27
-     * @param  \Illuminate\Support\Collection  $collection
28
-     * @param  string  $method
29
-     * @return void
30
-     */
31
-    public function __construct(Collection $collection, $method)
32
-    {
33
-        $this->method = $method;
34
-        $this->collection = $collection;
35
-    }
24
+	/**
25
+	 * Create a new proxy instance.
26
+	 *
27
+	 * @param  \Illuminate\Support\Collection  $collection
28
+	 * @param  string  $method
29
+	 * @return void
30
+	 */
31
+	public function __construct(Collection $collection, $method)
32
+	{
33
+		$this->method = $method;
34
+		$this->collection = $collection;
35
+	}
36 36
 
37
-    /**
38
-     * Proxy accessing an attribute onto the collection items.
39
-     *
40
-     * @param  string  $key
41
-     * @return mixed
42
-     */
43
-    public function __get($key)
44
-    {
45
-        return $this->collection->{$this->method}(function ($value) use ($key) {
46
-            return is_array($value) ? $value[$key] : $value->{$key};
47
-        });
48
-    }
37
+	/**
38
+	 * Proxy accessing an attribute onto the collection items.
39
+	 *
40
+	 * @param  string  $key
41
+	 * @return mixed
42
+	 */
43
+	public function __get($key)
44
+	{
45
+		return $this->collection->{$this->method}(function ($value) use ($key) {
46
+			return is_array($value) ? $value[$key] : $value->{$key};
47
+		});
48
+	}
49 49
 
50
-    /**
51
-     * Proxy a method call onto the collection items.
52
-     *
53
-     * @param  string  $method
54
-     * @param  array  $parameters
55
-     * @return mixed
56
-     */
57
-    public function __call($method, $parameters)
58
-    {
59
-        return $this->collection->{$this->method}(function ($value) use ($method, $parameters) {
60
-            return $value->{$method}(...$parameters);
61
-        });
62
-    }
50
+	/**
51
+	 * Proxy a method call onto the collection items.
52
+	 *
53
+	 * @param  string  $method
54
+	 * @param  array  $parameters
55
+	 * @return mixed
56
+	 */
57
+	public function __call($method, $parameters)
58
+	{
59
+		return $this->collection->{$this->method}(function ($value) use ($method, $parameters) {
60
+			return $value->{$method}(...$parameters);
61
+		});
62
+	}
63 63
 }
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
      * @param  string  $method
29 29
      * @return void
30 30
      */
31
-    public function __construct(Collection $collection, $method)
31
+    public function __construct( Collection $collection, $method )
32 32
     {
33 33
         $this->method = $method;
34 34
         $this->collection = $collection;
@@ -40,10 +40,10 @@  discard block
 block discarded – undo
40 40
      * @param  string  $key
41 41
      * @return mixed
42 42
      */
43
-    public function __get($key)
43
+    public function __get( $key )
44 44
     {
45
-        return $this->collection->{$this->method}(function ($value) use ($key) {
46
-            return is_array($value) ? $value[$key] : $value->{$key};
45
+        return $this->collection->{$this->method}( function( $value ) use ( $key ) {
46
+            return is_array( $value ) ? $value[ $key ] : $value->{$key};
47 47
         });
48 48
     }
49 49
 
@@ -54,10 +54,10 @@  discard block
 block discarded – undo
54 54
      * @param  array  $parameters
55 55
      * @return mixed
56 56
      */
57
-    public function __call($method, $parameters)
57
+    public function __call( $method, $parameters )
58 58
     {
59
-        return $this->collection->{$this->method}(function ($value) use ($method, $parameters) {
60
-            return $value->{$method}(...$parameters);
59
+        return $this->collection->{$this->method}( function( $value ) use ( $method, $parameters ) {
60
+            return $value->{$method}( ...$parameters );
61 61
         });
62 62
     }
63 63
 }
Please login to merge, or discard this patch.
Braces   +4 added lines, -8 removed lines patch added patch discarded remove patch
@@ -5,8 +5,7 @@  discard block
 block discarded – undo
5 5
 /**
6 6
  * @mixin \Illuminate\Support\Collection
7 7
  */
8
-class HigherOrderCollectionProxy
9
-{
8
+class HigherOrderCollectionProxy {
10 9
     /**
11 10
      * The collection being operated on.
12 11
      *
@@ -28,8 +27,7 @@  discard block
 block discarded – undo
28 27
      * @param  string  $method
29 28
      * @return void
30 29
      */
31
-    public function __construct(Collection $collection, $method)
32
-    {
30
+    public function __construct(Collection $collection, $method) {
33 31
         $this->method = $method;
34 32
         $this->collection = $collection;
35 33
     }
@@ -40,8 +38,7 @@  discard block
 block discarded – undo
40 38
      * @param  string  $key
41 39
      * @return mixed
42 40
      */
43
-    public function __get($key)
44
-    {
41
+    public function __get($key) {
45 42
         return $this->collection->{$this->method}(function ($value) use ($key) {
46 43
             return is_array($value) ? $value[$key] : $value->{$key};
47 44
         });
@@ -54,8 +51,7 @@  discard block
 block discarded – undo
54 51
      * @param  array  $parameters
55 52
      * @return mixed
56 53
      */
57
-    public function __call($method, $parameters)
58
-    {
54
+    public function __call($method, $parameters) {
59 55
         return $this->collection->{$this->method}(function ($value) use ($method, $parameters) {
60 56
             return $value->{$method}(...$parameters);
61 57
         });
Please login to merge, or discard this patch.
vendor/illuminate/support/Collection.php 3 patches
Indentation   +1636 added lines, -1636 removed lines patch added patch discarded remove patch
@@ -16,1640 +16,1640 @@
 block discarded – undo
16 16
 
17 17
 class Collection implements ArrayAccess, Arrayable, Countable, IteratorAggregate, Jsonable, JsonSerializable
18 18
 {
19
-    use Macroable;
20
-
21
-    /**
22
-     * The items contained in the collection.
23
-     *
24
-     * @var array
25
-     */
26
-    protected $items = [];
27
-
28
-    /**
29
-     * The methods that can be proxied.
30
-     *
31
-     * @var array
32
-     */
33
-    protected static $proxies = [
34
-        'average', 'avg', 'contains', 'each', 'every', 'filter', 'first', 'flatMap',
35
-        'map', 'partition', 'reject', 'sortBy', 'sortByDesc', 'sum',
36
-    ];
37
-
38
-    /**
39
-     * Create a new collection.
40
-     *
41
-     * @param  mixed  $items
42
-     * @return void
43
-     */
44
-    public function __construct($items = [])
45
-    {
46
-        $this->items = $this->getArrayableItems($items);
47
-    }
48
-
49
-    /**
50
-     * Create a new collection instance if the value isn't one already.
51
-     *
52
-     * @param  mixed  $items
53
-     * @return static
54
-     */
55
-    public static function make($items = [])
56
-    {
57
-        return new static($items);
58
-    }
59
-
60
-    /**
61
-     * Create a new collection by invoking the callback a given number of times.
62
-     *
63
-     * @param  int  $number
64
-     * @param  callable  $callback
65
-     * @return static
66
-     */
67
-    public static function times($number, callable $callback = null)
68
-    {
69
-        if ($number < 1) {
70
-            return new static;
71
-        }
72
-
73
-        if (is_null($callback)) {
74
-            return new static(range(1, $number));
75
-        }
76
-
77
-        return (new static(range(1, $number)))->map($callback);
78
-    }
79
-
80
-    /**
81
-     * Get all of the items in the collection.
82
-     *
83
-     * @return array
84
-     */
85
-    public function all()
86
-    {
87
-        return $this->items;
88
-    }
89
-
90
-    /**
91
-     * Get the average value of a given key.
92
-     *
93
-     * @param  callable|string|null  $callback
94
-     * @return mixed
95
-     */
96
-    public function avg($callback = null)
97
-    {
98
-        if ($count = $this->count()) {
99
-            return $this->sum($callback) / $count;
100
-        }
101
-    }
102
-
103
-    /**
104
-     * Alias for the "avg" method.
105
-     *
106
-     * @param  callable|string|null  $callback
107
-     * @return mixed
108
-     */
109
-    public function average($callback = null)
110
-    {
111
-        return $this->avg($callback);
112
-    }
113
-
114
-    /**
115
-     * Get the median of a given key.
116
-     *
117
-     * @param  null $key
118
-     * @return mixed
119
-     */
120
-    public function median($key = null)
121
-    {
122
-        $count = $this->count();
123
-
124
-        if ($count == 0) {
125
-            return;
126
-        }
127
-
128
-        $values = with(isset($key) ? $this->pluck($key) : $this)
129
-                    ->sort()->values();
130
-
131
-        $middle = (int) ($count / 2);
132
-
133
-        if ($count % 2) {
134
-            return $values->get($middle);
135
-        }
136
-
137
-        return (new static([
138
-            $values->get($middle - 1), $values->get($middle),
139
-        ]))->average();
140
-    }
141
-
142
-    /**
143
-     * Get the mode of a given key.
144
-     *
145
-     * @param  mixed  $key
146
-     * @return array|null
147
-     */
148
-    public function mode($key = null)
149
-    {
150
-        $count = $this->count();
151
-
152
-        if ($count == 0) {
153
-            return;
154
-        }
155
-
156
-        $collection = isset($key) ? $this->pluck($key) : $this;
157
-
158
-        $counts = new self;
159
-
160
-        $collection->each(function ($value) use ($counts) {
161
-            $counts[$value] = isset($counts[$value]) ? $counts[$value] + 1 : 1;
162
-        });
163
-
164
-        $sorted = $counts->sort();
165
-
166
-        $highestValue = $sorted->last();
167
-
168
-        return $sorted->filter(function ($value) use ($highestValue) {
169
-            return $value == $highestValue;
170
-        })->sort()->keys()->all();
171
-    }
172
-
173
-    /**
174
-     * Collapse the collection of items into a single array.
175
-     *
176
-     * @return static
177
-     */
178
-    public function collapse()
179
-    {
180
-        return new static(Arr::collapse($this->items));
181
-    }
182
-
183
-    /**
184
-     * Determine if an item exists in the collection.
185
-     *
186
-     * @param  mixed  $key
187
-     * @param  mixed  $operator
188
-     * @param  mixed  $value
189
-     * @return bool
190
-     */
191
-    public function contains($key, $operator = null, $value = null)
192
-    {
193
-        if (func_num_args() == 1) {
194
-            if ($this->useAsCallable($key)) {
195
-                return ! is_null($this->first($key));
196
-            }
197
-
198
-            return in_array($key, $this->items);
199
-        }
200
-
201
-        if (func_num_args() == 2) {
202
-            $value = $operator;
203
-
204
-            $operator = '=';
205
-        }
206
-
207
-        return $this->contains($this->operatorForWhere($key, $operator, $value));
208
-    }
209
-
210
-    /**
211
-     * Determine if an item exists in the collection using strict comparison.
212
-     *
213
-     * @param  mixed  $key
214
-     * @param  mixed  $value
215
-     * @return bool
216
-     */
217
-    public function containsStrict($key, $value = null)
218
-    {
219
-        if (func_num_args() == 2) {
220
-            return $this->contains(function ($item) use ($key, $value) {
221
-                return data_get($item, $key) === $value;
222
-            });
223
-        }
224
-
225
-        if ($this->useAsCallable($key)) {
226
-            return ! is_null($this->first($key));
227
-        }
228
-
229
-        return in_array($key, $this->items, true);
230
-    }
231
-
232
-    /**
233
-     * Cross join with the given lists, returning all possible permutations.
234
-     *
235
-     * @param  mixed  ...$lists
236
-     * @return static
237
-     */
238
-    public function crossJoin(...$lists)
239
-    {
240
-        return new static(Arr::crossJoin(
241
-            $this->items, ...array_map([$this, 'getArrayableItems'], $lists)
242
-        ));
243
-    }
244
-
245
-    /**
246
-     * Get the items in the collection that are not present in the given items.
247
-     *
248
-     * @param  mixed  $items
249
-     * @return static
250
-     */
251
-    public function diff($items)
252
-    {
253
-        return new static(array_diff($this->items, $this->getArrayableItems($items)));
254
-    }
255
-
256
-    /**
257
-     * Get the items in the collection whose keys and values are not present in the given items.
258
-     *
259
-     * @param  mixed  $items
260
-     * @return static
261
-     */
262
-    public function diffAssoc($items)
263
-    {
264
-        return new static(array_diff_assoc($this->items, $this->getArrayableItems($items)));
265
-    }
266
-
267
-    /**
268
-     * Get the items in the collection whose keys are not present in the given items.
269
-     *
270
-     * @param  mixed  $items
271
-     * @return static
272
-     */
273
-    public function diffKeys($items)
274
-    {
275
-        return new static(array_diff_key($this->items, $this->getArrayableItems($items)));
276
-    }
277
-
278
-    /**
279
-     * Execute a callback over each item.
280
-     *
281
-     * @param  callable  $callback
282
-     * @return $this
283
-     */
284
-    public function each(callable $callback)
285
-    {
286
-        foreach ($this->items as $key => $item) {
287
-            if ($callback($item, $key) === false) {
288
-                break;
289
-            }
290
-        }
291
-
292
-        return $this;
293
-    }
294
-
295
-    /**
296
-     * Execute a callback over each nested chunk of items.
297
-     *
298
-     * @param  callable  $callback
299
-     * @return static
300
-     */
301
-    public function eachSpread(callable $callback)
302
-    {
303
-        return $this->each(function ($chunk) use ($callback) {
304
-            return $callback(...$chunk);
305
-        });
306
-    }
307
-
308
-    /**
309
-     * Determine if all items in the collection pass the given test.
310
-     *
311
-     * @param  string|callable  $key
312
-     * @param  mixed  $operator
313
-     * @param  mixed  $value
314
-     * @return bool
315
-     */
316
-    public function every($key, $operator = null, $value = null)
317
-    {
318
-        if (func_num_args() == 1) {
319
-            $callback = $this->valueRetriever($key);
320
-
321
-            foreach ($this->items as $k => $v) {
322
-                if (! $callback($v, $k)) {
323
-                    return false;
324
-                }
325
-            }
326
-
327
-            return true;
328
-        }
329
-
330
-        if (func_num_args() == 2) {
331
-            $value = $operator;
332
-
333
-            $operator = '=';
334
-        }
335
-
336
-        return $this->every($this->operatorForWhere($key, $operator, $value));
337
-    }
338
-
339
-    /**
340
-     * Get all items except for those with the specified keys.
341
-     *
342
-     * @param  mixed  $keys
343
-     * @return static
344
-     */
345
-    public function except($keys)
346
-    {
347
-        $keys = is_array($keys) ? $keys : func_get_args();
348
-
349
-        return new static(Arr::except($this->items, $keys));
350
-    }
351
-
352
-    /**
353
-     * Run a filter over each of the items.
354
-     *
355
-     * @param  callable|null  $callback
356
-     * @return static
357
-     */
358
-    public function filter(callable $callback = null)
359
-    {
360
-        if ($callback) {
361
-            return new static(Arr::where($this->items, $callback));
362
-        }
363
-
364
-        return new static(array_filter($this->items));
365
-    }
366
-
367
-    /**
368
-     * Apply the callback if the value is truthy.
369
-     *
370
-     * @param  bool  $value
371
-     * @param  callable  $callback
372
-     * @param  callable  $default
373
-     * @return mixed
374
-     */
375
-    public function when($value, callable $callback, callable $default = null)
376
-    {
377
-        if ($value) {
378
-            return $callback($this);
379
-        } elseif ($default) {
380
-            return $default($this);
381
-        }
382
-
383
-        return $this;
384
-    }
385
-
386
-    /**
387
-     * Apply the callback if the value is falsy.
388
-     *
389
-     * @param  bool  $value
390
-     * @param  callable  $callback
391
-     * @param  callable  $default
392
-     * @return mixed
393
-     */
394
-    public function unless($value, callable $callback, callable $default = null)
395
-    {
396
-        return $this->when(! $value, $callback, $default);
397
-    }
398
-
399
-    /**
400
-     * Filter items by the given key value pair.
401
-     *
402
-     * @param  string  $key
403
-     * @param  mixed  $operator
404
-     * @param  mixed  $value
405
-     * @return static
406
-     */
407
-    public function where($key, $operator, $value = null)
408
-    {
409
-        if (func_num_args() == 2) {
410
-            $value = $operator;
411
-
412
-            $operator = '=';
413
-        }
414
-
415
-        return $this->filter($this->operatorForWhere($key, $operator, $value));
416
-    }
417
-
418
-    /**
419
-     * Get an operator checker callback.
420
-     *
421
-     * @param  string  $key
422
-     * @param  string  $operator
423
-     * @param  mixed  $value
424
-     * @return \Closure
425
-     */
426
-    protected function operatorForWhere($key, $operator, $value)
427
-    {
428
-        return function ($item) use ($key, $operator, $value) {
429
-            $retrieved = data_get($item, $key);
430
-
431
-            switch ($operator) {
432
-                default:
433
-                case '=':
434
-                case '==':  return $retrieved == $value;
435
-                case '!=':
436
-                case '<>':  return $retrieved != $value;
437
-                case '<':   return $retrieved < $value;
438
-                case '>':   return $retrieved > $value;
439
-                case '<=':  return $retrieved <= $value;
440
-                case '>=':  return $retrieved >= $value;
441
-                case '===': return $retrieved === $value;
442
-                case '!==': return $retrieved !== $value;
443
-            }
444
-        };
445
-    }
446
-
447
-    /**
448
-     * Filter items by the given key value pair using strict comparison.
449
-     *
450
-     * @param  string  $key
451
-     * @param  mixed  $value
452
-     * @return static
453
-     */
454
-    public function whereStrict($key, $value)
455
-    {
456
-        return $this->where($key, '===', $value);
457
-    }
458
-
459
-    /**
460
-     * Filter items by the given key value pair.
461
-     *
462
-     * @param  string  $key
463
-     * @param  mixed  $values
464
-     * @param  bool  $strict
465
-     * @return static
466
-     */
467
-    public function whereIn($key, $values, $strict = false)
468
-    {
469
-        $values = $this->getArrayableItems($values);
470
-
471
-        return $this->filter(function ($item) use ($key, $values, $strict) {
472
-            return in_array(data_get($item, $key), $values, $strict);
473
-        });
474
-    }
475
-
476
-    /**
477
-     * Filter items by the given key value pair using strict comparison.
478
-     *
479
-     * @param  string  $key
480
-     * @param  mixed  $values
481
-     * @return static
482
-     */
483
-    public function whereInStrict($key, $values)
484
-    {
485
-        return $this->whereIn($key, $values, true);
486
-    }
487
-
488
-    /**
489
-     * Filter items by the given key value pair.
490
-     *
491
-     * @param  string  $key
492
-     * @param  mixed  $values
493
-     * @param  bool  $strict
494
-     * @return static
495
-     */
496
-    public function whereNotIn($key, $values, $strict = false)
497
-    {
498
-        $values = $this->getArrayableItems($values);
499
-
500
-        return $this->reject(function ($item) use ($key, $values, $strict) {
501
-            return in_array(data_get($item, $key), $values, $strict);
502
-        });
503
-    }
504
-
505
-    /**
506
-     * Filter items by the given key value pair using strict comparison.
507
-     *
508
-     * @param  string  $key
509
-     * @param  mixed  $values
510
-     * @return static
511
-     */
512
-    public function whereNotInStrict($key, $values)
513
-    {
514
-        return $this->whereNotIn($key, $values, true);
515
-    }
516
-
517
-    /**
518
-     * Get the first item from the collection.
519
-     *
520
-     * @param  callable|null  $callback
521
-     * @param  mixed  $default
522
-     * @return mixed
523
-     */
524
-    public function first(callable $callback = null, $default = null)
525
-    {
526
-        return Arr::first($this->items, $callback, $default);
527
-    }
528
-
529
-    /**
530
-     * Get a flattened array of the items in the collection.
531
-     *
532
-     * @param  int  $depth
533
-     * @return static
534
-     */
535
-    public function flatten($depth = INF)
536
-    {
537
-        return new static(Arr::flatten($this->items, $depth));
538
-    }
539
-
540
-    /**
541
-     * Flip the items in the collection.
542
-     *
543
-     * @return static
544
-     */
545
-    public function flip()
546
-    {
547
-        return new static(array_flip($this->items));
548
-    }
549
-
550
-    /**
551
-     * Remove an item from the collection by key.
552
-     *
553
-     * @param  string|array  $keys
554
-     * @return $this
555
-     */
556
-    public function forget($keys)
557
-    {
558
-        foreach ((array) $keys as $key) {
559
-            $this->offsetUnset($key);
560
-        }
561
-
562
-        return $this;
563
-    }
564
-
565
-    /**
566
-     * Get an item from the collection by key.
567
-     *
568
-     * @param  mixed  $key
569
-     * @param  mixed  $default
570
-     * @return mixed
571
-     */
572
-    public function get($key, $default = null)
573
-    {
574
-        if ($this->offsetExists($key)) {
575
-            return $this->items[$key];
576
-        }
577
-
578
-        return value($default);
579
-    }
580
-
581
-    /**
582
-     * Group an associative array by a field or using a callback.
583
-     *
584
-     * @param  callable|string  $groupBy
585
-     * @param  bool  $preserveKeys
586
-     * @return static
587
-     */
588
-    public function groupBy($groupBy, $preserveKeys = false)
589
-    {
590
-        $groupBy = $this->valueRetriever($groupBy);
591
-
592
-        $results = [];
593
-
594
-        foreach ($this->items as $key => $value) {
595
-            $groupKeys = $groupBy($value, $key);
596
-
597
-            if (! is_array($groupKeys)) {
598
-                $groupKeys = [$groupKeys];
599
-            }
600
-
601
-            foreach ($groupKeys as $groupKey) {
602
-                $groupKey = is_bool($groupKey) ? (int) $groupKey : $groupKey;
603
-
604
-                if (! array_key_exists($groupKey, $results)) {
605
-                    $results[$groupKey] = new static;
606
-                }
607
-
608
-                $results[$groupKey]->offsetSet($preserveKeys ? $key : null, $value);
609
-            }
610
-        }
611
-
612
-        return new static($results);
613
-    }
614
-
615
-    /**
616
-     * Key an associative array by a field or using a callback.
617
-     *
618
-     * @param  callable|string  $keyBy
619
-     * @return static
620
-     */
621
-    public function keyBy($keyBy)
622
-    {
623
-        $keyBy = $this->valueRetriever($keyBy);
624
-
625
-        $results = [];
626
-
627
-        foreach ($this->items as $key => $item) {
628
-            $resolvedKey = $keyBy($item, $key);
629
-
630
-            if (is_object($resolvedKey)) {
631
-                $resolvedKey = (string) $resolvedKey;
632
-            }
633
-
634
-            $results[$resolvedKey] = $item;
635
-        }
636
-
637
-        return new static($results);
638
-    }
639
-
640
-    /**
641
-     * Determine if an item exists in the collection by key.
642
-     *
643
-     * @param  mixed  $key
644
-     * @return bool
645
-     */
646
-    public function has($key)
647
-    {
648
-        return $this->offsetExists($key);
649
-    }
650
-
651
-    /**
652
-     * Concatenate values of a given key as a string.
653
-     *
654
-     * @param  string  $value
655
-     * @param  string  $glue
656
-     * @return string
657
-     */
658
-    public function implode($value, $glue = null)
659
-    {
660
-        $first = $this->first();
661
-
662
-        if (is_array($first) || is_object($first)) {
663
-            return implode($glue, $this->pluck($value)->all());
664
-        }
665
-
666
-        return implode($value, $this->items);
667
-    }
668
-
669
-    /**
670
-     * Intersect the collection with the given items.
671
-     *
672
-     * @param  mixed  $items
673
-     * @return static
674
-     */
675
-    public function intersect($items)
676
-    {
677
-        return new static(array_intersect($this->items, $this->getArrayableItems($items)));
678
-    }
679
-
680
-    /**
681
-     * Intersect the collection with the given items by key.
682
-     *
683
-     * @param  mixed  $items
684
-     * @return static
685
-     */
686
-    public function intersectKey($items)
687
-    {
688
-        return new static(array_intersect_key($this->items, $this->getArrayableItems($items)));
689
-    }
690
-
691
-    /**
692
-     * Determine if the collection is empty or not.
693
-     *
694
-     * @return bool
695
-     */
696
-    public function isEmpty()
697
-    {
698
-        return empty($this->items);
699
-    }
700
-
701
-    /**
702
-     * Determine if the collection is not empty.
703
-     *
704
-     * @return bool
705
-     */
706
-    public function isNotEmpty()
707
-    {
708
-        return ! $this->isEmpty();
709
-    }
710
-
711
-    /**
712
-     * Determine if the given value is callable, but not a string.
713
-     *
714
-     * @param  mixed  $value
715
-     * @return bool
716
-     */
717
-    protected function useAsCallable($value)
718
-    {
719
-        return ! is_string($value) && is_callable($value);
720
-    }
721
-
722
-    /**
723
-     * Get the keys of the collection items.
724
-     *
725
-     * @return static
726
-     */
727
-    public function keys()
728
-    {
729
-        return new static(array_keys($this->items));
730
-    }
731
-
732
-    /**
733
-     * Get the last item from the collection.
734
-     *
735
-     * @param  callable|null  $callback
736
-     * @param  mixed  $default
737
-     * @return mixed
738
-     */
739
-    public function last(callable $callback = null, $default = null)
740
-    {
741
-        return Arr::last($this->items, $callback, $default);
742
-    }
743
-
744
-    /**
745
-     * Get the values of a given key.
746
-     *
747
-     * @param  string|array  $value
748
-     * @param  string|null  $key
749
-     * @return static
750
-     */
751
-    public function pluck($value, $key = null)
752
-    {
753
-        return new static(Arr::pluck($this->items, $value, $key));
754
-    }
755
-
756
-    /**
757
-     * Run a map over each of the items.
758
-     *
759
-     * @param  callable  $callback
760
-     * @return static
761
-     */
762
-    public function map(callable $callback)
763
-    {
764
-        $keys = array_keys($this->items);
765
-
766
-        $items = array_map($callback, $this->items, $keys);
767
-
768
-        return new static(array_combine($keys, $items));
769
-    }
770
-
771
-    /**
772
-     * Run a map over each nested chunk of items.
773
-     *
774
-     * @param  callable  $callback
775
-     * @return static
776
-     */
777
-    public function mapSpread(callable $callback)
778
-    {
779
-        return $this->map(function ($chunk) use ($callback) {
780
-            return $callback(...$chunk);
781
-        });
782
-    }
783
-
784
-    /**
785
-     * Run a grouping map over the items.
786
-     *
787
-     * The callback should return an associative array with a single key/value pair.
788
-     *
789
-     * @param  callable  $callback
790
-     * @return static
791
-     */
792
-    public function mapToGroups(callable $callback)
793
-    {
794
-        $groups = $this->map($callback)->reduce(function ($groups, $pair) {
795
-            $groups[key($pair)][] = reset($pair);
796
-
797
-            return $groups;
798
-        }, []);
799
-
800
-        return (new static($groups))->map([$this, 'make']);
801
-    }
802
-
803
-    /**
804
-     * Run an associative map over each of the items.
805
-     *
806
-     * The callback should return an associative array with a single key/value pair.
807
-     *
808
-     * @param  callable  $callback
809
-     * @return static
810
-     */
811
-    public function mapWithKeys(callable $callback)
812
-    {
813
-        $result = [];
814
-
815
-        foreach ($this->items as $key => $value) {
816
-            $assoc = $callback($value, $key);
817
-
818
-            foreach ($assoc as $mapKey => $mapValue) {
819
-                $result[$mapKey] = $mapValue;
820
-            }
821
-        }
822
-
823
-        return new static($result);
824
-    }
825
-
826
-    /**
827
-     * Map a collection and flatten the result by a single level.
828
-     *
829
-     * @param  callable  $callback
830
-     * @return static
831
-     */
832
-    public function flatMap(callable $callback)
833
-    {
834
-        return $this->map($callback)->collapse();
835
-    }
836
-
837
-    /**
838
-     * Get the max value of a given key.
839
-     *
840
-     * @param  callable|string|null  $callback
841
-     * @return mixed
842
-     */
843
-    public function max($callback = null)
844
-    {
845
-        $callback = $this->valueRetriever($callback);
846
-
847
-        return $this->filter(function ($value) {
848
-            return ! is_null($value);
849
-        })->reduce(function ($result, $item) use ($callback) {
850
-            $value = $callback($item);
851
-
852
-            return is_null($result) || $value > $result ? $value : $result;
853
-        });
854
-    }
855
-
856
-    /**
857
-     * Merge the collection with the given items.
858
-     *
859
-     * @param  mixed  $items
860
-     * @return static
861
-     */
862
-    public function merge($items)
863
-    {
864
-        return new static(array_merge($this->items, $this->getArrayableItems($items)));
865
-    }
866
-
867
-    /**
868
-     * Create a collection by using this collection for keys and another for its values.
869
-     *
870
-     * @param  mixed  $values
871
-     * @return static
872
-     */
873
-    public function combine($values)
874
-    {
875
-        return new static(array_combine($this->all(), $this->getArrayableItems($values)));
876
-    }
877
-
878
-    /**
879
-     * Union the collection with the given items.
880
-     *
881
-     * @param  mixed  $items
882
-     * @return static
883
-     */
884
-    public function union($items)
885
-    {
886
-        return new static($this->items + $this->getArrayableItems($items));
887
-    }
888
-
889
-    /**
890
-     * Get the min value of a given key.
891
-     *
892
-     * @param  callable|string|null  $callback
893
-     * @return mixed
894
-     */
895
-    public function min($callback = null)
896
-    {
897
-        $callback = $this->valueRetriever($callback);
898
-
899
-        return $this->filter(function ($value) {
900
-            return ! is_null($value);
901
-        })->reduce(function ($result, $item) use ($callback) {
902
-            $value = $callback($item);
903
-
904
-            return is_null($result) || $value < $result ? $value : $result;
905
-        });
906
-    }
907
-
908
-    /**
909
-     * Create a new collection consisting of every n-th element.
910
-     *
911
-     * @param  int  $step
912
-     * @param  int  $offset
913
-     * @return static
914
-     */
915
-    public function nth($step, $offset = 0)
916
-    {
917
-        $new = [];
918
-
919
-        $position = 0;
920
-
921
-        foreach ($this->items as $item) {
922
-            if ($position % $step === $offset) {
923
-                $new[] = $item;
924
-            }
925
-
926
-            $position++;
927
-        }
928
-
929
-        return new static($new);
930
-    }
931
-
932
-    /**
933
-     * Get the items with the specified keys.
934
-     *
935
-     * @param  mixed  $keys
936
-     * @return static
937
-     */
938
-    public function only($keys)
939
-    {
940
-        if (is_null($keys)) {
941
-            return new static($this->items);
942
-        }
943
-
944
-        $keys = is_array($keys) ? $keys : func_get_args();
945
-
946
-        return new static(Arr::only($this->items, $keys));
947
-    }
948
-
949
-    /**
950
-     * "Paginate" the collection by slicing it into a smaller collection.
951
-     *
952
-     * @param  int  $page
953
-     * @param  int  $perPage
954
-     * @return static
955
-     */
956
-    public function forPage($page, $perPage)
957
-    {
958
-        return $this->slice(($page - 1) * $perPage, $perPage);
959
-    }
960
-
961
-    /**
962
-     * Partition the collection into two arrays using the given callback or key.
963
-     *
964
-     * @param  callable|string  $callback
965
-     * @return static
966
-     */
967
-    public function partition($callback)
968
-    {
969
-        $partitions = [new static, new static];
970
-
971
-        $callback = $this->valueRetriever($callback);
972
-
973
-        foreach ($this->items as $key => $item) {
974
-            $partitions[(int) ! $callback($item)][$key] = $item;
975
-        }
976
-
977
-        return new static($partitions);
978
-    }
979
-
980
-    /**
981
-     * Pass the collection to the given callback and return the result.
982
-     *
983
-     * @param  callable $callback
984
-     * @return mixed
985
-     */
986
-    public function pipe(callable $callback)
987
-    {
988
-        return $callback($this);
989
-    }
990
-
991
-    /**
992
-     * Get and remove the last item from the collection.
993
-     *
994
-     * @return mixed
995
-     */
996
-    public function pop()
997
-    {
998
-        return array_pop($this->items);
999
-    }
1000
-
1001
-    /**
1002
-     * Push an item onto the beginning of the collection.
1003
-     *
1004
-     * @param  mixed  $value
1005
-     * @param  mixed  $key
1006
-     * @return $this
1007
-     */
1008
-    public function prepend($value, $key = null)
1009
-    {
1010
-        $this->items = Arr::prepend($this->items, $value, $key);
1011
-
1012
-        return $this;
1013
-    }
1014
-
1015
-    /**
1016
-     * Push an item onto the end of the collection.
1017
-     *
1018
-     * @param  mixed  $value
1019
-     * @return $this
1020
-     */
1021
-    public function push($value)
1022
-    {
1023
-        $this->offsetSet(null, $value);
1024
-
1025
-        return $this;
1026
-    }
1027
-
1028
-    /**
1029
-     * Push all of the given items onto the collection.
1030
-     *
1031
-     * @param  \Traversable  $source
1032
-     * @return self
1033
-     */
1034
-    public function concat($source)
1035
-    {
1036
-        $result = new static($this);
1037
-
1038
-        foreach ($source as $item) {
1039
-            $result->push($item);
1040
-        }
1041
-
1042
-        return $result;
1043
-    }
1044
-
1045
-    /**
1046
-     * Get and remove an item from the collection.
1047
-     *
1048
-     * @param  mixed  $key
1049
-     * @param  mixed  $default
1050
-     * @return mixed
1051
-     */
1052
-    public function pull($key, $default = null)
1053
-    {
1054
-        return Arr::pull($this->items, $key, $default);
1055
-    }
1056
-
1057
-    /**
1058
-     * Put an item in the collection by key.
1059
-     *
1060
-     * @param  mixed  $key
1061
-     * @param  mixed  $value
1062
-     * @return $this
1063
-     */
1064
-    public function put($key, $value)
1065
-    {
1066
-        $this->offsetSet($key, $value);
1067
-
1068
-        return $this;
1069
-    }
1070
-
1071
-    /**
1072
-     * Get one or a specified number of items randomly from the collection.
1073
-     *
1074
-     * @param  int|null  $number
1075
-     * @return mixed
1076
-     *
1077
-     * @throws \InvalidArgumentException
1078
-     */
1079
-    public function random($number = null)
1080
-    {
1081
-        if (is_null($number)) {
1082
-            return Arr::random($this->items);
1083
-        }
1084
-
1085
-        return new static(Arr::random($this->items, $number));
1086
-    }
1087
-
1088
-    /**
1089
-     * Reduce the collection to a single value.
1090
-     *
1091
-     * @param  callable  $callback
1092
-     * @param  mixed  $initial
1093
-     * @return mixed
1094
-     */
1095
-    public function reduce(callable $callback, $initial = null)
1096
-    {
1097
-        return array_reduce($this->items, $callback, $initial);
1098
-    }
1099
-
1100
-    /**
1101
-     * Create a collection of all elements that do not pass a given truth test.
1102
-     *
1103
-     * @param  callable|mixed  $callback
1104
-     * @return static
1105
-     */
1106
-    public function reject($callback)
1107
-    {
1108
-        if ($this->useAsCallable($callback)) {
1109
-            return $this->filter(function ($value, $key) use ($callback) {
1110
-                return ! $callback($value, $key);
1111
-            });
1112
-        }
1113
-
1114
-        return $this->filter(function ($item) use ($callback) {
1115
-            return $item != $callback;
1116
-        });
1117
-    }
1118
-
1119
-    /**
1120
-     * Reverse items order.
1121
-     *
1122
-     * @return static
1123
-     */
1124
-    public function reverse()
1125
-    {
1126
-        return new static(array_reverse($this->items, true));
1127
-    }
1128
-
1129
-    /**
1130
-     * Search the collection for a given value and return the corresponding key if successful.
1131
-     *
1132
-     * @param  mixed  $value
1133
-     * @param  bool  $strict
1134
-     * @return mixed
1135
-     */
1136
-    public function search($value, $strict = false)
1137
-    {
1138
-        if (! $this->useAsCallable($value)) {
1139
-            return array_search($value, $this->items, $strict);
1140
-        }
1141
-
1142
-        foreach ($this->items as $key => $item) {
1143
-            if (call_user_func($value, $item, $key)) {
1144
-                return $key;
1145
-            }
1146
-        }
1147
-
1148
-        return false;
1149
-    }
1150
-
1151
-    /**
1152
-     * Get and remove the first item from the collection.
1153
-     *
1154
-     * @return mixed
1155
-     */
1156
-    public function shift()
1157
-    {
1158
-        return array_shift($this->items);
1159
-    }
1160
-
1161
-    /**
1162
-     * Shuffle the items in the collection.
1163
-     *
1164
-     * @param  int  $seed
1165
-     * @return static
1166
-     */
1167
-    public function shuffle($seed = null)
1168
-    {
1169
-        $items = $this->items;
1170
-
1171
-        if (is_null($seed)) {
1172
-            shuffle($items);
1173
-        } else {
1174
-            srand($seed);
1175
-
1176
-            usort($items, function () {
1177
-                return rand(-1, 1);
1178
-            });
1179
-        }
1180
-
1181
-        return new static($items);
1182
-    }
1183
-
1184
-    /**
1185
-     * Slice the underlying collection array.
1186
-     *
1187
-     * @param  int  $offset
1188
-     * @param  int  $length
1189
-     * @return static
1190
-     */
1191
-    public function slice($offset, $length = null)
1192
-    {
1193
-        return new static(array_slice($this->items, $offset, $length, true));
1194
-    }
1195
-
1196
-    /**
1197
-     * Split a collection into a certain number of groups.
1198
-     *
1199
-     * @param  int  $numberOfGroups
1200
-     * @return static
1201
-     */
1202
-    public function split($numberOfGroups)
1203
-    {
1204
-        if ($this->isEmpty()) {
1205
-            return new static;
1206
-        }
1207
-
1208
-        $groupSize = ceil($this->count() / $numberOfGroups);
1209
-
1210
-        return $this->chunk($groupSize);
1211
-    }
1212
-
1213
-    /**
1214
-     * Chunk the underlying collection array.
1215
-     *
1216
-     * @param  int  $size
1217
-     * @return static
1218
-     */
1219
-    public function chunk($size)
1220
-    {
1221
-        if ($size <= 0) {
1222
-            return new static;
1223
-        }
1224
-
1225
-        $chunks = [];
1226
-
1227
-        foreach (array_chunk($this->items, $size, true) as $chunk) {
1228
-            $chunks[] = new static($chunk);
1229
-        }
1230
-
1231
-        return new static($chunks);
1232
-    }
1233
-
1234
-    /**
1235
-     * Sort through each item with a callback.
1236
-     *
1237
-     * @param  callable|null  $callback
1238
-     * @return static
1239
-     */
1240
-    public function sort(callable $callback = null)
1241
-    {
1242
-        $items = $this->items;
1243
-
1244
-        $callback
1245
-            ? uasort($items, $callback)
1246
-            : asort($items);
1247
-
1248
-        return new static($items);
1249
-    }
1250
-
1251
-    /**
1252
-     * Sort the collection using the given callback.
1253
-     *
1254
-     * @param  callable|string  $callback
1255
-     * @param  int  $options
1256
-     * @param  bool  $descending
1257
-     * @return static
1258
-     */
1259
-    public function sortBy($callback, $options = SORT_REGULAR, $descending = false)
1260
-    {
1261
-        $results = [];
1262
-
1263
-        $callback = $this->valueRetriever($callback);
1264
-
1265
-        // First we will loop through the items and get the comparator from a callback
1266
-        // function which we were given. Then, we will sort the returned values and
1267
-        // and grab the corresponding values for the sorted keys from this array.
1268
-        foreach ($this->items as $key => $value) {
1269
-            $results[$key] = $callback($value, $key);
1270
-        }
1271
-
1272
-        $descending ? arsort($results, $options)
1273
-                    : asort($results, $options);
1274
-
1275
-        // Once we have sorted all of the keys in the array, we will loop through them
1276
-        // and grab the corresponding model so we can set the underlying items list
1277
-        // to the sorted version. Then we'll just return the collection instance.
1278
-        foreach (array_keys($results) as $key) {
1279
-            $results[$key] = $this->items[$key];
1280
-        }
1281
-
1282
-        return new static($results);
1283
-    }
1284
-
1285
-    /**
1286
-     * Sort the collection in descending order using the given callback.
1287
-     *
1288
-     * @param  callable|string  $callback
1289
-     * @param  int  $options
1290
-     * @return static
1291
-     */
1292
-    public function sortByDesc($callback, $options = SORT_REGULAR)
1293
-    {
1294
-        return $this->sortBy($callback, $options, true);
1295
-    }
1296
-
1297
-    /**
1298
-     * Splice a portion of the underlying collection array.
1299
-     *
1300
-     * @param  int  $offset
1301
-     * @param  int|null  $length
1302
-     * @param  mixed  $replacement
1303
-     * @return static
1304
-     */
1305
-    public function splice($offset, $length = null, $replacement = [])
1306
-    {
1307
-        if (func_num_args() == 1) {
1308
-            return new static(array_splice($this->items, $offset));
1309
-        }
1310
-
1311
-        return new static(array_splice($this->items, $offset, $length, $replacement));
1312
-    }
1313
-
1314
-    /**
1315
-     * Get the sum of the given values.
1316
-     *
1317
-     * @param  callable|string|null  $callback
1318
-     * @return mixed
1319
-     */
1320
-    public function sum($callback = null)
1321
-    {
1322
-        if (is_null($callback)) {
1323
-            return array_sum($this->items);
1324
-        }
1325
-
1326
-        $callback = $this->valueRetriever($callback);
1327
-
1328
-        return $this->reduce(function ($result, $item) use ($callback) {
1329
-            return $result + $callback($item);
1330
-        }, 0);
1331
-    }
1332
-
1333
-    /**
1334
-     * Take the first or last {$limit} items.
1335
-     *
1336
-     * @param  int  $limit
1337
-     * @return static
1338
-     */
1339
-    public function take($limit)
1340
-    {
1341
-        if ($limit < 0) {
1342
-            return $this->slice($limit, abs($limit));
1343
-        }
1344
-
1345
-        return $this->slice(0, $limit);
1346
-    }
1347
-
1348
-    /**
1349
-     * Pass the collection to the given callback and then return it.
1350
-     *
1351
-     * @param  callable  $callback
1352
-     * @return $this
1353
-     */
1354
-    public function tap(callable $callback)
1355
-    {
1356
-        $callback(new static($this->items));
1357
-
1358
-        return $this;
1359
-    }
1360
-
1361
-    /**
1362
-     * Transform each item in the collection using a callback.
1363
-     *
1364
-     * @param  callable  $callback
1365
-     * @return $this
1366
-     */
1367
-    public function transform(callable $callback)
1368
-    {
1369
-        $this->items = $this->map($callback)->all();
1370
-
1371
-        return $this;
1372
-    }
1373
-
1374
-    /**
1375
-     * Return only unique items from the collection array.
1376
-     *
1377
-     * @param  string|callable|null  $key
1378
-     * @param  bool  $strict
1379
-     * @return static
1380
-     */
1381
-    public function unique($key = null, $strict = false)
1382
-    {
1383
-        if (is_null($key)) {
1384
-            return new static(array_unique($this->items, SORT_REGULAR));
1385
-        }
1386
-
1387
-        $callback = $this->valueRetriever($key);
1388
-
1389
-        $exists = [];
1390
-
1391
-        return $this->reject(function ($item, $key) use ($callback, $strict, &$exists) {
1392
-            if (in_array($id = $callback($item, $key), $exists, $strict)) {
1393
-                return true;
1394
-            }
1395
-
1396
-            $exists[] = $id;
1397
-        });
1398
-    }
1399
-
1400
-    /**
1401
-     * Return only unique items from the collection array using strict comparison.
1402
-     *
1403
-     * @param  string|callable|null  $key
1404
-     * @return static
1405
-     */
1406
-    public function uniqueStrict($key = null)
1407
-    {
1408
-        return $this->unique($key, true);
1409
-    }
1410
-
1411
-    /**
1412
-     * Reset the keys on the underlying array.
1413
-     *
1414
-     * @return static
1415
-     */
1416
-    public function values()
1417
-    {
1418
-        return new static(array_values($this->items));
1419
-    }
1420
-
1421
-    /**
1422
-     * Get a value retrieving callback.
1423
-     *
1424
-     * @param  string  $value
1425
-     * @return callable
1426
-     */
1427
-    protected function valueRetriever($value)
1428
-    {
1429
-        if ($this->useAsCallable($value)) {
1430
-            return $value;
1431
-        }
1432
-
1433
-        return function ($item) use ($value) {
1434
-            return data_get($item, $value);
1435
-        };
1436
-    }
1437
-
1438
-    /**
1439
-     * Zip the collection together with one or more arrays.
1440
-     *
1441
-     * e.g. new Collection([1, 2, 3])->zip([4, 5, 6]);
1442
-     *      => [[1, 4], [2, 5], [3, 6]]
1443
-     *
1444
-     * @param  mixed ...$items
1445
-     * @return static
1446
-     */
1447
-    public function zip($items)
1448
-    {
1449
-        $arrayableItems = array_map(function ($items) {
1450
-            return $this->getArrayableItems($items);
1451
-        }, func_get_args());
1452
-
1453
-        $params = array_merge([function () {
1454
-            return new static(func_get_args());
1455
-        }, $this->items], $arrayableItems);
1456
-
1457
-        return new static(call_user_func_array('array_map', $params));
1458
-    }
1459
-
1460
-    /**
1461
-     * Get the collection of items as a plain array.
1462
-     *
1463
-     * @return array
1464
-     */
1465
-    public function toArray()
1466
-    {
1467
-        return array_map(function ($value) {
1468
-            return $value instanceof Arrayable ? $value->toArray() : $value;
1469
-        }, $this->items);
1470
-    }
1471
-
1472
-    /**
1473
-     * Convert the object into something JSON serializable.
1474
-     *
1475
-     * @return array
1476
-     */
1477
-    public function jsonSerialize()
1478
-    {
1479
-        return array_map(function ($value) {
1480
-            if ($value instanceof JsonSerializable) {
1481
-                return $value->jsonSerialize();
1482
-            } elseif ($value instanceof Jsonable) {
1483
-                return json_decode($value->toJson(), true);
1484
-            } elseif ($value instanceof Arrayable) {
1485
-                return $value->toArray();
1486
-            } else {
1487
-                return $value;
1488
-            }
1489
-        }, $this->items);
1490
-    }
1491
-
1492
-    /**
1493
-     * Get the collection of items as JSON.
1494
-     *
1495
-     * @param  int  $options
1496
-     * @return string
1497
-     */
1498
-    public function toJson($options = 0)
1499
-    {
1500
-        return json_encode($this->jsonSerialize(), $options);
1501
-    }
1502
-
1503
-    /**
1504
-     * Get an iterator for the items.
1505
-     *
1506
-     * @return \ArrayIterator
1507
-     */
1508
-    public function getIterator()
1509
-    {
1510
-        return new ArrayIterator($this->items);
1511
-    }
1512
-
1513
-    /**
1514
-     * Get a CachingIterator instance.
1515
-     *
1516
-     * @param  int  $flags
1517
-     * @return \CachingIterator
1518
-     */
1519
-    public function getCachingIterator($flags = CachingIterator::CALL_TOSTRING)
1520
-    {
1521
-        return new CachingIterator($this->getIterator(), $flags);
1522
-    }
1523
-
1524
-    /**
1525
-     * Count the number of items in the collection.
1526
-     *
1527
-     * @return int
1528
-     */
1529
-    public function count()
1530
-    {
1531
-        return count($this->items);
1532
-    }
1533
-
1534
-    /**
1535
-     * Get a base Support collection instance from this collection.
1536
-     *
1537
-     * @return \Illuminate\Support\Collection
1538
-     */
1539
-    public function toBase()
1540
-    {
1541
-        return new self($this);
1542
-    }
1543
-
1544
-    /**
1545
-     * Determine if an item exists at an offset.
1546
-     *
1547
-     * @param  mixed  $key
1548
-     * @return bool
1549
-     */
1550
-    public function offsetExists($key)
1551
-    {
1552
-        return array_key_exists($key, $this->items);
1553
-    }
1554
-
1555
-    /**
1556
-     * Get an item at a given offset.
1557
-     *
1558
-     * @param  mixed  $key
1559
-     * @return mixed
1560
-     */
1561
-    public function offsetGet($key)
1562
-    {
1563
-        return $this->items[$key];
1564
-    }
1565
-
1566
-    /**
1567
-     * Set the item at a given offset.
1568
-     *
1569
-     * @param  mixed  $key
1570
-     * @param  mixed  $value
1571
-     * @return void
1572
-     */
1573
-    public function offsetSet($key, $value)
1574
-    {
1575
-        if (is_null($key)) {
1576
-            $this->items[] = $value;
1577
-        } else {
1578
-            $this->items[$key] = $value;
1579
-        }
1580
-    }
1581
-
1582
-    /**
1583
-     * Unset the item at a given offset.
1584
-     *
1585
-     * @param  string  $key
1586
-     * @return void
1587
-     */
1588
-    public function offsetUnset($key)
1589
-    {
1590
-        unset($this->items[$key]);
1591
-    }
1592
-
1593
-    /**
1594
-     * Convert the collection to its string representation.
1595
-     *
1596
-     * @return string
1597
-     */
1598
-    public function __toString()
1599
-    {
1600
-        return $this->toJson();
1601
-    }
1602
-
1603
-    /**
1604
-     * Results array of items from Collection or Arrayable.
1605
-     *
1606
-     * @param  mixed  $items
1607
-     * @return array
1608
-     */
1609
-    protected function getArrayableItems($items)
1610
-    {
1611
-        if (is_array($items)) {
1612
-            return $items;
1613
-        } elseif ($items instanceof self) {
1614
-            return $items->all();
1615
-        } elseif ($items instanceof Arrayable) {
1616
-            return $items->toArray();
1617
-        } elseif ($items instanceof Jsonable) {
1618
-            return json_decode($items->toJson(), true);
1619
-        } elseif ($items instanceof JsonSerializable) {
1620
-            return $items->jsonSerialize();
1621
-        } elseif ($items instanceof Traversable) {
1622
-            return iterator_to_array($items);
1623
-        }
1624
-
1625
-        return (array) $items;
1626
-    }
1627
-
1628
-    /**
1629
-     * Add a method to the list of proxied methods.
1630
-     *
1631
-     * @param  string  $method
1632
-     * @return void
1633
-     */
1634
-    public static function proxy($method)
1635
-    {
1636
-        static::$proxies[] = $method;
1637
-    }
1638
-
1639
-    /**
1640
-     * Dynamically access collection proxies.
1641
-     *
1642
-     * @param  string  $key
1643
-     * @return mixed
1644
-     *
1645
-     * @throws \Exception
1646
-     */
1647
-    public function __get($key)
1648
-    {
1649
-        if (! in_array($key, static::$proxies)) {
1650
-            throw new Exception("Property [{$key}] does not exist on this collection instance.");
1651
-        }
1652
-
1653
-        return new HigherOrderCollectionProxy($this, $key);
1654
-    }
19
+	use Macroable;
20
+
21
+	/**
22
+	 * The items contained in the collection.
23
+	 *
24
+	 * @var array
25
+	 */
26
+	protected $items = [];
27
+
28
+	/**
29
+	 * The methods that can be proxied.
30
+	 *
31
+	 * @var array
32
+	 */
33
+	protected static $proxies = [
34
+		'average', 'avg', 'contains', 'each', 'every', 'filter', 'first', 'flatMap',
35
+		'map', 'partition', 'reject', 'sortBy', 'sortByDesc', 'sum',
36
+	];
37
+
38
+	/**
39
+	 * Create a new collection.
40
+	 *
41
+	 * @param  mixed  $items
42
+	 * @return void
43
+	 */
44
+	public function __construct($items = [])
45
+	{
46
+		$this->items = $this->getArrayableItems($items);
47
+	}
48
+
49
+	/**
50
+	 * Create a new collection instance if the value isn't one already.
51
+	 *
52
+	 * @param  mixed  $items
53
+	 * @return static
54
+	 */
55
+	public static function make($items = [])
56
+	{
57
+		return new static($items);
58
+	}
59
+
60
+	/**
61
+	 * Create a new collection by invoking the callback a given number of times.
62
+	 *
63
+	 * @param  int  $number
64
+	 * @param  callable  $callback
65
+	 * @return static
66
+	 */
67
+	public static function times($number, callable $callback = null)
68
+	{
69
+		if ($number < 1) {
70
+			return new static;
71
+		}
72
+
73
+		if (is_null($callback)) {
74
+			return new static(range(1, $number));
75
+		}
76
+
77
+		return (new static(range(1, $number)))->map($callback);
78
+	}
79
+
80
+	/**
81
+	 * Get all of the items in the collection.
82
+	 *
83
+	 * @return array
84
+	 */
85
+	public function all()
86
+	{
87
+		return $this->items;
88
+	}
89
+
90
+	/**
91
+	 * Get the average value of a given key.
92
+	 *
93
+	 * @param  callable|string|null  $callback
94
+	 * @return mixed
95
+	 */
96
+	public function avg($callback = null)
97
+	{
98
+		if ($count = $this->count()) {
99
+			return $this->sum($callback) / $count;
100
+		}
101
+	}
102
+
103
+	/**
104
+	 * Alias for the "avg" method.
105
+	 *
106
+	 * @param  callable|string|null  $callback
107
+	 * @return mixed
108
+	 */
109
+	public function average($callback = null)
110
+	{
111
+		return $this->avg($callback);
112
+	}
113
+
114
+	/**
115
+	 * Get the median of a given key.
116
+	 *
117
+	 * @param  null $key
118
+	 * @return mixed
119
+	 */
120
+	public function median($key = null)
121
+	{
122
+		$count = $this->count();
123
+
124
+		if ($count == 0) {
125
+			return;
126
+		}
127
+
128
+		$values = with(isset($key) ? $this->pluck($key) : $this)
129
+					->sort()->values();
130
+
131
+		$middle = (int) ($count / 2);
132
+
133
+		if ($count % 2) {
134
+			return $values->get($middle);
135
+		}
136
+
137
+		return (new static([
138
+			$values->get($middle - 1), $values->get($middle),
139
+		]))->average();
140
+	}
141
+
142
+	/**
143
+	 * Get the mode of a given key.
144
+	 *
145
+	 * @param  mixed  $key
146
+	 * @return array|null
147
+	 */
148
+	public function mode($key = null)
149
+	{
150
+		$count = $this->count();
151
+
152
+		if ($count == 0) {
153
+			return;
154
+		}
155
+
156
+		$collection = isset($key) ? $this->pluck($key) : $this;
157
+
158
+		$counts = new self;
159
+
160
+		$collection->each(function ($value) use ($counts) {
161
+			$counts[$value] = isset($counts[$value]) ? $counts[$value] + 1 : 1;
162
+		});
163
+
164
+		$sorted = $counts->sort();
165
+
166
+		$highestValue = $sorted->last();
167
+
168
+		return $sorted->filter(function ($value) use ($highestValue) {
169
+			return $value == $highestValue;
170
+		})->sort()->keys()->all();
171
+	}
172
+
173
+	/**
174
+	 * Collapse the collection of items into a single array.
175
+	 *
176
+	 * @return static
177
+	 */
178
+	public function collapse()
179
+	{
180
+		return new static(Arr::collapse($this->items));
181
+	}
182
+
183
+	/**
184
+	 * Determine if an item exists in the collection.
185
+	 *
186
+	 * @param  mixed  $key
187
+	 * @param  mixed  $operator
188
+	 * @param  mixed  $value
189
+	 * @return bool
190
+	 */
191
+	public function contains($key, $operator = null, $value = null)
192
+	{
193
+		if (func_num_args() == 1) {
194
+			if ($this->useAsCallable($key)) {
195
+				return ! is_null($this->first($key));
196
+			}
197
+
198
+			return in_array($key, $this->items);
199
+		}
200
+
201
+		if (func_num_args() == 2) {
202
+			$value = $operator;
203
+
204
+			$operator = '=';
205
+		}
206
+
207
+		return $this->contains($this->operatorForWhere($key, $operator, $value));
208
+	}
209
+
210
+	/**
211
+	 * Determine if an item exists in the collection using strict comparison.
212
+	 *
213
+	 * @param  mixed  $key
214
+	 * @param  mixed  $value
215
+	 * @return bool
216
+	 */
217
+	public function containsStrict($key, $value = null)
218
+	{
219
+		if (func_num_args() == 2) {
220
+			return $this->contains(function ($item) use ($key, $value) {
221
+				return data_get($item, $key) === $value;
222
+			});
223
+		}
224
+
225
+		if ($this->useAsCallable($key)) {
226
+			return ! is_null($this->first($key));
227
+		}
228
+
229
+		return in_array($key, $this->items, true);
230
+	}
231
+
232
+	/**
233
+	 * Cross join with the given lists, returning all possible permutations.
234
+	 *
235
+	 * @param  mixed  ...$lists
236
+	 * @return static
237
+	 */
238
+	public function crossJoin(...$lists)
239
+	{
240
+		return new static(Arr::crossJoin(
241
+			$this->items, ...array_map([$this, 'getArrayableItems'], $lists)
242
+		));
243
+	}
244
+
245
+	/**
246
+	 * Get the items in the collection that are not present in the given items.
247
+	 *
248
+	 * @param  mixed  $items
249
+	 * @return static
250
+	 */
251
+	public function diff($items)
252
+	{
253
+		return new static(array_diff($this->items, $this->getArrayableItems($items)));
254
+	}
255
+
256
+	/**
257
+	 * Get the items in the collection whose keys and values are not present in the given items.
258
+	 *
259
+	 * @param  mixed  $items
260
+	 * @return static
261
+	 */
262
+	public function diffAssoc($items)
263
+	{
264
+		return new static(array_diff_assoc($this->items, $this->getArrayableItems($items)));
265
+	}
266
+
267
+	/**
268
+	 * Get the items in the collection whose keys are not present in the given items.
269
+	 *
270
+	 * @param  mixed  $items
271
+	 * @return static
272
+	 */
273
+	public function diffKeys($items)
274
+	{
275
+		return new static(array_diff_key($this->items, $this->getArrayableItems($items)));
276
+	}
277
+
278
+	/**
279
+	 * Execute a callback over each item.
280
+	 *
281
+	 * @param  callable  $callback
282
+	 * @return $this
283
+	 */
284
+	public function each(callable $callback)
285
+	{
286
+		foreach ($this->items as $key => $item) {
287
+			if ($callback($item, $key) === false) {
288
+				break;
289
+			}
290
+		}
291
+
292
+		return $this;
293
+	}
294
+
295
+	/**
296
+	 * Execute a callback over each nested chunk of items.
297
+	 *
298
+	 * @param  callable  $callback
299
+	 * @return static
300
+	 */
301
+	public function eachSpread(callable $callback)
302
+	{
303
+		return $this->each(function ($chunk) use ($callback) {
304
+			return $callback(...$chunk);
305
+		});
306
+	}
307
+
308
+	/**
309
+	 * Determine if all items in the collection pass the given test.
310
+	 *
311
+	 * @param  string|callable  $key
312
+	 * @param  mixed  $operator
313
+	 * @param  mixed  $value
314
+	 * @return bool
315
+	 */
316
+	public function every($key, $operator = null, $value = null)
317
+	{
318
+		if (func_num_args() == 1) {
319
+			$callback = $this->valueRetriever($key);
320
+
321
+			foreach ($this->items as $k => $v) {
322
+				if (! $callback($v, $k)) {
323
+					return false;
324
+				}
325
+			}
326
+
327
+			return true;
328
+		}
329
+
330
+		if (func_num_args() == 2) {
331
+			$value = $operator;
332
+
333
+			$operator = '=';
334
+		}
335
+
336
+		return $this->every($this->operatorForWhere($key, $operator, $value));
337
+	}
338
+
339
+	/**
340
+	 * Get all items except for those with the specified keys.
341
+	 *
342
+	 * @param  mixed  $keys
343
+	 * @return static
344
+	 */
345
+	public function except($keys)
346
+	{
347
+		$keys = is_array($keys) ? $keys : func_get_args();
348
+
349
+		return new static(Arr::except($this->items, $keys));
350
+	}
351
+
352
+	/**
353
+	 * Run a filter over each of the items.
354
+	 *
355
+	 * @param  callable|null  $callback
356
+	 * @return static
357
+	 */
358
+	public function filter(callable $callback = null)
359
+	{
360
+		if ($callback) {
361
+			return new static(Arr::where($this->items, $callback));
362
+		}
363
+
364
+		return new static(array_filter($this->items));
365
+	}
366
+
367
+	/**
368
+	 * Apply the callback if the value is truthy.
369
+	 *
370
+	 * @param  bool  $value
371
+	 * @param  callable  $callback
372
+	 * @param  callable  $default
373
+	 * @return mixed
374
+	 */
375
+	public function when($value, callable $callback, callable $default = null)
376
+	{
377
+		if ($value) {
378
+			return $callback($this);
379
+		} elseif ($default) {
380
+			return $default($this);
381
+		}
382
+
383
+		return $this;
384
+	}
385
+
386
+	/**
387
+	 * Apply the callback if the value is falsy.
388
+	 *
389
+	 * @param  bool  $value
390
+	 * @param  callable  $callback
391
+	 * @param  callable  $default
392
+	 * @return mixed
393
+	 */
394
+	public function unless($value, callable $callback, callable $default = null)
395
+	{
396
+		return $this->when(! $value, $callback, $default);
397
+	}
398
+
399
+	/**
400
+	 * Filter items by the given key value pair.
401
+	 *
402
+	 * @param  string  $key
403
+	 * @param  mixed  $operator
404
+	 * @param  mixed  $value
405
+	 * @return static
406
+	 */
407
+	public function where($key, $operator, $value = null)
408
+	{
409
+		if (func_num_args() == 2) {
410
+			$value = $operator;
411
+
412
+			$operator = '=';
413
+		}
414
+
415
+		return $this->filter($this->operatorForWhere($key, $operator, $value));
416
+	}
417
+
418
+	/**
419
+	 * Get an operator checker callback.
420
+	 *
421
+	 * @param  string  $key
422
+	 * @param  string  $operator
423
+	 * @param  mixed  $value
424
+	 * @return \Closure
425
+	 */
426
+	protected function operatorForWhere($key, $operator, $value)
427
+	{
428
+		return function ($item) use ($key, $operator, $value) {
429
+			$retrieved = data_get($item, $key);
430
+
431
+			switch ($operator) {
432
+				default:
433
+				case '=':
434
+				case '==':  return $retrieved == $value;
435
+				case '!=':
436
+				case '<>':  return $retrieved != $value;
437
+				case '<':   return $retrieved < $value;
438
+				case '>':   return $retrieved > $value;
439
+				case '<=':  return $retrieved <= $value;
440
+				case '>=':  return $retrieved >= $value;
441
+				case '===': return $retrieved === $value;
442
+				case '!==': return $retrieved !== $value;
443
+			}
444
+		};
445
+	}
446
+
447
+	/**
448
+	 * Filter items by the given key value pair using strict comparison.
449
+	 *
450
+	 * @param  string  $key
451
+	 * @param  mixed  $value
452
+	 * @return static
453
+	 */
454
+	public function whereStrict($key, $value)
455
+	{
456
+		return $this->where($key, '===', $value);
457
+	}
458
+
459
+	/**
460
+	 * Filter items by the given key value pair.
461
+	 *
462
+	 * @param  string  $key
463
+	 * @param  mixed  $values
464
+	 * @param  bool  $strict
465
+	 * @return static
466
+	 */
467
+	public function whereIn($key, $values, $strict = false)
468
+	{
469
+		$values = $this->getArrayableItems($values);
470
+
471
+		return $this->filter(function ($item) use ($key, $values, $strict) {
472
+			return in_array(data_get($item, $key), $values, $strict);
473
+		});
474
+	}
475
+
476
+	/**
477
+	 * Filter items by the given key value pair using strict comparison.
478
+	 *
479
+	 * @param  string  $key
480
+	 * @param  mixed  $values
481
+	 * @return static
482
+	 */
483
+	public function whereInStrict($key, $values)
484
+	{
485
+		return $this->whereIn($key, $values, true);
486
+	}
487
+
488
+	/**
489
+	 * Filter items by the given key value pair.
490
+	 *
491
+	 * @param  string  $key
492
+	 * @param  mixed  $values
493
+	 * @param  bool  $strict
494
+	 * @return static
495
+	 */
496
+	public function whereNotIn($key, $values, $strict = false)
497
+	{
498
+		$values = $this->getArrayableItems($values);
499
+
500
+		return $this->reject(function ($item) use ($key, $values, $strict) {
501
+			return in_array(data_get($item, $key), $values, $strict);
502
+		});
503
+	}
504
+
505
+	/**
506
+	 * Filter items by the given key value pair using strict comparison.
507
+	 *
508
+	 * @param  string  $key
509
+	 * @param  mixed  $values
510
+	 * @return static
511
+	 */
512
+	public function whereNotInStrict($key, $values)
513
+	{
514
+		return $this->whereNotIn($key, $values, true);
515
+	}
516
+
517
+	/**
518
+	 * Get the first item from the collection.
519
+	 *
520
+	 * @param  callable|null  $callback
521
+	 * @param  mixed  $default
522
+	 * @return mixed
523
+	 */
524
+	public function first(callable $callback = null, $default = null)
525
+	{
526
+		return Arr::first($this->items, $callback, $default);
527
+	}
528
+
529
+	/**
530
+	 * Get a flattened array of the items in the collection.
531
+	 *
532
+	 * @param  int  $depth
533
+	 * @return static
534
+	 */
535
+	public function flatten($depth = INF)
536
+	{
537
+		return new static(Arr::flatten($this->items, $depth));
538
+	}
539
+
540
+	/**
541
+	 * Flip the items in the collection.
542
+	 *
543
+	 * @return static
544
+	 */
545
+	public function flip()
546
+	{
547
+		return new static(array_flip($this->items));
548
+	}
549
+
550
+	/**
551
+	 * Remove an item from the collection by key.
552
+	 *
553
+	 * @param  string|array  $keys
554
+	 * @return $this
555
+	 */
556
+	public function forget($keys)
557
+	{
558
+		foreach ((array) $keys as $key) {
559
+			$this->offsetUnset($key);
560
+		}
561
+
562
+		return $this;
563
+	}
564
+
565
+	/**
566
+	 * Get an item from the collection by key.
567
+	 *
568
+	 * @param  mixed  $key
569
+	 * @param  mixed  $default
570
+	 * @return mixed
571
+	 */
572
+	public function get($key, $default = null)
573
+	{
574
+		if ($this->offsetExists($key)) {
575
+			return $this->items[$key];
576
+		}
577
+
578
+		return value($default);
579
+	}
580
+
581
+	/**
582
+	 * Group an associative array by a field or using a callback.
583
+	 *
584
+	 * @param  callable|string  $groupBy
585
+	 * @param  bool  $preserveKeys
586
+	 * @return static
587
+	 */
588
+	public function groupBy($groupBy, $preserveKeys = false)
589
+	{
590
+		$groupBy = $this->valueRetriever($groupBy);
591
+
592
+		$results = [];
593
+
594
+		foreach ($this->items as $key => $value) {
595
+			$groupKeys = $groupBy($value, $key);
596
+
597
+			if (! is_array($groupKeys)) {
598
+				$groupKeys = [$groupKeys];
599
+			}
600
+
601
+			foreach ($groupKeys as $groupKey) {
602
+				$groupKey = is_bool($groupKey) ? (int) $groupKey : $groupKey;
603
+
604
+				if (! array_key_exists($groupKey, $results)) {
605
+					$results[$groupKey] = new static;
606
+				}
607
+
608
+				$results[$groupKey]->offsetSet($preserveKeys ? $key : null, $value);
609
+			}
610
+		}
611
+
612
+		return new static($results);
613
+	}
614
+
615
+	/**
616
+	 * Key an associative array by a field or using a callback.
617
+	 *
618
+	 * @param  callable|string  $keyBy
619
+	 * @return static
620
+	 */
621
+	public function keyBy($keyBy)
622
+	{
623
+		$keyBy = $this->valueRetriever($keyBy);
624
+
625
+		$results = [];
626
+
627
+		foreach ($this->items as $key => $item) {
628
+			$resolvedKey = $keyBy($item, $key);
629
+
630
+			if (is_object($resolvedKey)) {
631
+				$resolvedKey = (string) $resolvedKey;
632
+			}
633
+
634
+			$results[$resolvedKey] = $item;
635
+		}
636
+
637
+		return new static($results);
638
+	}
639
+
640
+	/**
641
+	 * Determine if an item exists in the collection by key.
642
+	 *
643
+	 * @param  mixed  $key
644
+	 * @return bool
645
+	 */
646
+	public function has($key)
647
+	{
648
+		return $this->offsetExists($key);
649
+	}
650
+
651
+	/**
652
+	 * Concatenate values of a given key as a string.
653
+	 *
654
+	 * @param  string  $value
655
+	 * @param  string  $glue
656
+	 * @return string
657
+	 */
658
+	public function implode($value, $glue = null)
659
+	{
660
+		$first = $this->first();
661
+
662
+		if (is_array($first) || is_object($first)) {
663
+			return implode($glue, $this->pluck($value)->all());
664
+		}
665
+
666
+		return implode($value, $this->items);
667
+	}
668
+
669
+	/**
670
+	 * Intersect the collection with the given items.
671
+	 *
672
+	 * @param  mixed  $items
673
+	 * @return static
674
+	 */
675
+	public function intersect($items)
676
+	{
677
+		return new static(array_intersect($this->items, $this->getArrayableItems($items)));
678
+	}
679
+
680
+	/**
681
+	 * Intersect the collection with the given items by key.
682
+	 *
683
+	 * @param  mixed  $items
684
+	 * @return static
685
+	 */
686
+	public function intersectKey($items)
687
+	{
688
+		return new static(array_intersect_key($this->items, $this->getArrayableItems($items)));
689
+	}
690
+
691
+	/**
692
+	 * Determine if the collection is empty or not.
693
+	 *
694
+	 * @return bool
695
+	 */
696
+	public function isEmpty()
697
+	{
698
+		return empty($this->items);
699
+	}
700
+
701
+	/**
702
+	 * Determine if the collection is not empty.
703
+	 *
704
+	 * @return bool
705
+	 */
706
+	public function isNotEmpty()
707
+	{
708
+		return ! $this->isEmpty();
709
+	}
710
+
711
+	/**
712
+	 * Determine if the given value is callable, but not a string.
713
+	 *
714
+	 * @param  mixed  $value
715
+	 * @return bool
716
+	 */
717
+	protected function useAsCallable($value)
718
+	{
719
+		return ! is_string($value) && is_callable($value);
720
+	}
721
+
722
+	/**
723
+	 * Get the keys of the collection items.
724
+	 *
725
+	 * @return static
726
+	 */
727
+	public function keys()
728
+	{
729
+		return new static(array_keys($this->items));
730
+	}
731
+
732
+	/**
733
+	 * Get the last item from the collection.
734
+	 *
735
+	 * @param  callable|null  $callback
736
+	 * @param  mixed  $default
737
+	 * @return mixed
738
+	 */
739
+	public function last(callable $callback = null, $default = null)
740
+	{
741
+		return Arr::last($this->items, $callback, $default);
742
+	}
743
+
744
+	/**
745
+	 * Get the values of a given key.
746
+	 *
747
+	 * @param  string|array  $value
748
+	 * @param  string|null  $key
749
+	 * @return static
750
+	 */
751
+	public function pluck($value, $key = null)
752
+	{
753
+		return new static(Arr::pluck($this->items, $value, $key));
754
+	}
755
+
756
+	/**
757
+	 * Run a map over each of the items.
758
+	 *
759
+	 * @param  callable  $callback
760
+	 * @return static
761
+	 */
762
+	public function map(callable $callback)
763
+	{
764
+		$keys = array_keys($this->items);
765
+
766
+		$items = array_map($callback, $this->items, $keys);
767
+
768
+		return new static(array_combine($keys, $items));
769
+	}
770
+
771
+	/**
772
+	 * Run a map over each nested chunk of items.
773
+	 *
774
+	 * @param  callable  $callback
775
+	 * @return static
776
+	 */
777
+	public function mapSpread(callable $callback)
778
+	{
779
+		return $this->map(function ($chunk) use ($callback) {
780
+			return $callback(...$chunk);
781
+		});
782
+	}
783
+
784
+	/**
785
+	 * Run a grouping map over the items.
786
+	 *
787
+	 * The callback should return an associative array with a single key/value pair.
788
+	 *
789
+	 * @param  callable  $callback
790
+	 * @return static
791
+	 */
792
+	public function mapToGroups(callable $callback)
793
+	{
794
+		$groups = $this->map($callback)->reduce(function ($groups, $pair) {
795
+			$groups[key($pair)][] = reset($pair);
796
+
797
+			return $groups;
798
+		}, []);
799
+
800
+		return (new static($groups))->map([$this, 'make']);
801
+	}
802
+
803
+	/**
804
+	 * Run an associative map over each of the items.
805
+	 *
806
+	 * The callback should return an associative array with a single key/value pair.
807
+	 *
808
+	 * @param  callable  $callback
809
+	 * @return static
810
+	 */
811
+	public function mapWithKeys(callable $callback)
812
+	{
813
+		$result = [];
814
+
815
+		foreach ($this->items as $key => $value) {
816
+			$assoc = $callback($value, $key);
817
+
818
+			foreach ($assoc as $mapKey => $mapValue) {
819
+				$result[$mapKey] = $mapValue;
820
+			}
821
+		}
822
+
823
+		return new static($result);
824
+	}
825
+
826
+	/**
827
+	 * Map a collection and flatten the result by a single level.
828
+	 *
829
+	 * @param  callable  $callback
830
+	 * @return static
831
+	 */
832
+	public function flatMap(callable $callback)
833
+	{
834
+		return $this->map($callback)->collapse();
835
+	}
836
+
837
+	/**
838
+	 * Get the max value of a given key.
839
+	 *
840
+	 * @param  callable|string|null  $callback
841
+	 * @return mixed
842
+	 */
843
+	public function max($callback = null)
844
+	{
845
+		$callback = $this->valueRetriever($callback);
846
+
847
+		return $this->filter(function ($value) {
848
+			return ! is_null($value);
849
+		})->reduce(function ($result, $item) use ($callback) {
850
+			$value = $callback($item);
851
+
852
+			return is_null($result) || $value > $result ? $value : $result;
853
+		});
854
+	}
855
+
856
+	/**
857
+	 * Merge the collection with the given items.
858
+	 *
859
+	 * @param  mixed  $items
860
+	 * @return static
861
+	 */
862
+	public function merge($items)
863
+	{
864
+		return new static(array_merge($this->items, $this->getArrayableItems($items)));
865
+	}
866
+
867
+	/**
868
+	 * Create a collection by using this collection for keys and another for its values.
869
+	 *
870
+	 * @param  mixed  $values
871
+	 * @return static
872
+	 */
873
+	public function combine($values)
874
+	{
875
+		return new static(array_combine($this->all(), $this->getArrayableItems($values)));
876
+	}
877
+
878
+	/**
879
+	 * Union the collection with the given items.
880
+	 *
881
+	 * @param  mixed  $items
882
+	 * @return static
883
+	 */
884
+	public function union($items)
885
+	{
886
+		return new static($this->items + $this->getArrayableItems($items));
887
+	}
888
+
889
+	/**
890
+	 * Get the min value of a given key.
891
+	 *
892
+	 * @param  callable|string|null  $callback
893
+	 * @return mixed
894
+	 */
895
+	public function min($callback = null)
896
+	{
897
+		$callback = $this->valueRetriever($callback);
898
+
899
+		return $this->filter(function ($value) {
900
+			return ! is_null($value);
901
+		})->reduce(function ($result, $item) use ($callback) {
902
+			$value = $callback($item);
903
+
904
+			return is_null($result) || $value < $result ? $value : $result;
905
+		});
906
+	}
907
+
908
+	/**
909
+	 * Create a new collection consisting of every n-th element.
910
+	 *
911
+	 * @param  int  $step
912
+	 * @param  int  $offset
913
+	 * @return static
914
+	 */
915
+	public function nth($step, $offset = 0)
916
+	{
917
+		$new = [];
918
+
919
+		$position = 0;
920
+
921
+		foreach ($this->items as $item) {
922
+			if ($position % $step === $offset) {
923
+				$new[] = $item;
924
+			}
925
+
926
+			$position++;
927
+		}
928
+
929
+		return new static($new);
930
+	}
931
+
932
+	/**
933
+	 * Get the items with the specified keys.
934
+	 *
935
+	 * @param  mixed  $keys
936
+	 * @return static
937
+	 */
938
+	public function only($keys)
939
+	{
940
+		if (is_null($keys)) {
941
+			return new static($this->items);
942
+		}
943
+
944
+		$keys = is_array($keys) ? $keys : func_get_args();
945
+
946
+		return new static(Arr::only($this->items, $keys));
947
+	}
948
+
949
+	/**
950
+	 * "Paginate" the collection by slicing it into a smaller collection.
951
+	 *
952
+	 * @param  int  $page
953
+	 * @param  int  $perPage
954
+	 * @return static
955
+	 */
956
+	public function forPage($page, $perPage)
957
+	{
958
+		return $this->slice(($page - 1) * $perPage, $perPage);
959
+	}
960
+
961
+	/**
962
+	 * Partition the collection into two arrays using the given callback or key.
963
+	 *
964
+	 * @param  callable|string  $callback
965
+	 * @return static
966
+	 */
967
+	public function partition($callback)
968
+	{
969
+		$partitions = [new static, new static];
970
+
971
+		$callback = $this->valueRetriever($callback);
972
+
973
+		foreach ($this->items as $key => $item) {
974
+			$partitions[(int) ! $callback($item)][$key] = $item;
975
+		}
976
+
977
+		return new static($partitions);
978
+	}
979
+
980
+	/**
981
+	 * Pass the collection to the given callback and return the result.
982
+	 *
983
+	 * @param  callable $callback
984
+	 * @return mixed
985
+	 */
986
+	public function pipe(callable $callback)
987
+	{
988
+		return $callback($this);
989
+	}
990
+
991
+	/**
992
+	 * Get and remove the last item from the collection.
993
+	 *
994
+	 * @return mixed
995
+	 */
996
+	public function pop()
997
+	{
998
+		return array_pop($this->items);
999
+	}
1000
+
1001
+	/**
1002
+	 * Push an item onto the beginning of the collection.
1003
+	 *
1004
+	 * @param  mixed  $value
1005
+	 * @param  mixed  $key
1006
+	 * @return $this
1007
+	 */
1008
+	public function prepend($value, $key = null)
1009
+	{
1010
+		$this->items = Arr::prepend($this->items, $value, $key);
1011
+
1012
+		return $this;
1013
+	}
1014
+
1015
+	/**
1016
+	 * Push an item onto the end of the collection.
1017
+	 *
1018
+	 * @param  mixed  $value
1019
+	 * @return $this
1020
+	 */
1021
+	public function push($value)
1022
+	{
1023
+		$this->offsetSet(null, $value);
1024
+
1025
+		return $this;
1026
+	}
1027
+
1028
+	/**
1029
+	 * Push all of the given items onto the collection.
1030
+	 *
1031
+	 * @param  \Traversable  $source
1032
+	 * @return self
1033
+	 */
1034
+	public function concat($source)
1035
+	{
1036
+		$result = new static($this);
1037
+
1038
+		foreach ($source as $item) {
1039
+			$result->push($item);
1040
+		}
1041
+
1042
+		return $result;
1043
+	}
1044
+
1045
+	/**
1046
+	 * Get and remove an item from the collection.
1047
+	 *
1048
+	 * @param  mixed  $key
1049
+	 * @param  mixed  $default
1050
+	 * @return mixed
1051
+	 */
1052
+	public function pull($key, $default = null)
1053
+	{
1054
+		return Arr::pull($this->items, $key, $default);
1055
+	}
1056
+
1057
+	/**
1058
+	 * Put an item in the collection by key.
1059
+	 *
1060
+	 * @param  mixed  $key
1061
+	 * @param  mixed  $value
1062
+	 * @return $this
1063
+	 */
1064
+	public function put($key, $value)
1065
+	{
1066
+		$this->offsetSet($key, $value);
1067
+
1068
+		return $this;
1069
+	}
1070
+
1071
+	/**
1072
+	 * Get one or a specified number of items randomly from the collection.
1073
+	 *
1074
+	 * @param  int|null  $number
1075
+	 * @return mixed
1076
+	 *
1077
+	 * @throws \InvalidArgumentException
1078
+	 */
1079
+	public function random($number = null)
1080
+	{
1081
+		if (is_null($number)) {
1082
+			return Arr::random($this->items);
1083
+		}
1084
+
1085
+		return new static(Arr::random($this->items, $number));
1086
+	}
1087
+
1088
+	/**
1089
+	 * Reduce the collection to a single value.
1090
+	 *
1091
+	 * @param  callable  $callback
1092
+	 * @param  mixed  $initial
1093
+	 * @return mixed
1094
+	 */
1095
+	public function reduce(callable $callback, $initial = null)
1096
+	{
1097
+		return array_reduce($this->items, $callback, $initial);
1098
+	}
1099
+
1100
+	/**
1101
+	 * Create a collection of all elements that do not pass a given truth test.
1102
+	 *
1103
+	 * @param  callable|mixed  $callback
1104
+	 * @return static
1105
+	 */
1106
+	public function reject($callback)
1107
+	{
1108
+		if ($this->useAsCallable($callback)) {
1109
+			return $this->filter(function ($value, $key) use ($callback) {
1110
+				return ! $callback($value, $key);
1111
+			});
1112
+		}
1113
+
1114
+		return $this->filter(function ($item) use ($callback) {
1115
+			return $item != $callback;
1116
+		});
1117
+	}
1118
+
1119
+	/**
1120
+	 * Reverse items order.
1121
+	 *
1122
+	 * @return static
1123
+	 */
1124
+	public function reverse()
1125
+	{
1126
+		return new static(array_reverse($this->items, true));
1127
+	}
1128
+
1129
+	/**
1130
+	 * Search the collection for a given value and return the corresponding key if successful.
1131
+	 *
1132
+	 * @param  mixed  $value
1133
+	 * @param  bool  $strict
1134
+	 * @return mixed
1135
+	 */
1136
+	public function search($value, $strict = false)
1137
+	{
1138
+		if (! $this->useAsCallable($value)) {
1139
+			return array_search($value, $this->items, $strict);
1140
+		}
1141
+
1142
+		foreach ($this->items as $key => $item) {
1143
+			if (call_user_func($value, $item, $key)) {
1144
+				return $key;
1145
+			}
1146
+		}
1147
+
1148
+		return false;
1149
+	}
1150
+
1151
+	/**
1152
+	 * Get and remove the first item from the collection.
1153
+	 *
1154
+	 * @return mixed
1155
+	 */
1156
+	public function shift()
1157
+	{
1158
+		return array_shift($this->items);
1159
+	}
1160
+
1161
+	/**
1162
+	 * Shuffle the items in the collection.
1163
+	 *
1164
+	 * @param  int  $seed
1165
+	 * @return static
1166
+	 */
1167
+	public function shuffle($seed = null)
1168
+	{
1169
+		$items = $this->items;
1170
+
1171
+		if (is_null($seed)) {
1172
+			shuffle($items);
1173
+		} else {
1174
+			srand($seed);
1175
+
1176
+			usort($items, function () {
1177
+				return rand(-1, 1);
1178
+			});
1179
+		}
1180
+
1181
+		return new static($items);
1182
+	}
1183
+
1184
+	/**
1185
+	 * Slice the underlying collection array.
1186
+	 *
1187
+	 * @param  int  $offset
1188
+	 * @param  int  $length
1189
+	 * @return static
1190
+	 */
1191
+	public function slice($offset, $length = null)
1192
+	{
1193
+		return new static(array_slice($this->items, $offset, $length, true));
1194
+	}
1195
+
1196
+	/**
1197
+	 * Split a collection into a certain number of groups.
1198
+	 *
1199
+	 * @param  int  $numberOfGroups
1200
+	 * @return static
1201
+	 */
1202
+	public function split($numberOfGroups)
1203
+	{
1204
+		if ($this->isEmpty()) {
1205
+			return new static;
1206
+		}
1207
+
1208
+		$groupSize = ceil($this->count() / $numberOfGroups);
1209
+
1210
+		return $this->chunk($groupSize);
1211
+	}
1212
+
1213
+	/**
1214
+	 * Chunk the underlying collection array.
1215
+	 *
1216
+	 * @param  int  $size
1217
+	 * @return static
1218
+	 */
1219
+	public function chunk($size)
1220
+	{
1221
+		if ($size <= 0) {
1222
+			return new static;
1223
+		}
1224
+
1225
+		$chunks = [];
1226
+
1227
+		foreach (array_chunk($this->items, $size, true) as $chunk) {
1228
+			$chunks[] = new static($chunk);
1229
+		}
1230
+
1231
+		return new static($chunks);
1232
+	}
1233
+
1234
+	/**
1235
+	 * Sort through each item with a callback.
1236
+	 *
1237
+	 * @param  callable|null  $callback
1238
+	 * @return static
1239
+	 */
1240
+	public function sort(callable $callback = null)
1241
+	{
1242
+		$items = $this->items;
1243
+
1244
+		$callback
1245
+			? uasort($items, $callback)
1246
+			: asort($items);
1247
+
1248
+		return new static($items);
1249
+	}
1250
+
1251
+	/**
1252
+	 * Sort the collection using the given callback.
1253
+	 *
1254
+	 * @param  callable|string  $callback
1255
+	 * @param  int  $options
1256
+	 * @param  bool  $descending
1257
+	 * @return static
1258
+	 */
1259
+	public function sortBy($callback, $options = SORT_REGULAR, $descending = false)
1260
+	{
1261
+		$results = [];
1262
+
1263
+		$callback = $this->valueRetriever($callback);
1264
+
1265
+		// First we will loop through the items and get the comparator from a callback
1266
+		// function which we were given. Then, we will sort the returned values and
1267
+		// and grab the corresponding values for the sorted keys from this array.
1268
+		foreach ($this->items as $key => $value) {
1269
+			$results[$key] = $callback($value, $key);
1270
+		}
1271
+
1272
+		$descending ? arsort($results, $options)
1273
+					: asort($results, $options);
1274
+
1275
+		// Once we have sorted all of the keys in the array, we will loop through them
1276
+		// and grab the corresponding model so we can set the underlying items list
1277
+		// to the sorted version. Then we'll just return the collection instance.
1278
+		foreach (array_keys($results) as $key) {
1279
+			$results[$key] = $this->items[$key];
1280
+		}
1281
+
1282
+		return new static($results);
1283
+	}
1284
+
1285
+	/**
1286
+	 * Sort the collection in descending order using the given callback.
1287
+	 *
1288
+	 * @param  callable|string  $callback
1289
+	 * @param  int  $options
1290
+	 * @return static
1291
+	 */
1292
+	public function sortByDesc($callback, $options = SORT_REGULAR)
1293
+	{
1294
+		return $this->sortBy($callback, $options, true);
1295
+	}
1296
+
1297
+	/**
1298
+	 * Splice a portion of the underlying collection array.
1299
+	 *
1300
+	 * @param  int  $offset
1301
+	 * @param  int|null  $length
1302
+	 * @param  mixed  $replacement
1303
+	 * @return static
1304
+	 */
1305
+	public function splice($offset, $length = null, $replacement = [])
1306
+	{
1307
+		if (func_num_args() == 1) {
1308
+			return new static(array_splice($this->items, $offset));
1309
+		}
1310
+
1311
+		return new static(array_splice($this->items, $offset, $length, $replacement));
1312
+	}
1313
+
1314
+	/**
1315
+	 * Get the sum of the given values.
1316
+	 *
1317
+	 * @param  callable|string|null  $callback
1318
+	 * @return mixed
1319
+	 */
1320
+	public function sum($callback = null)
1321
+	{
1322
+		if (is_null($callback)) {
1323
+			return array_sum($this->items);
1324
+		}
1325
+
1326
+		$callback = $this->valueRetriever($callback);
1327
+
1328
+		return $this->reduce(function ($result, $item) use ($callback) {
1329
+			return $result + $callback($item);
1330
+		}, 0);
1331
+	}
1332
+
1333
+	/**
1334
+	 * Take the first or last {$limit} items.
1335
+	 *
1336
+	 * @param  int  $limit
1337
+	 * @return static
1338
+	 */
1339
+	public function take($limit)
1340
+	{
1341
+		if ($limit < 0) {
1342
+			return $this->slice($limit, abs($limit));
1343
+		}
1344
+
1345
+		return $this->slice(0, $limit);
1346
+	}
1347
+
1348
+	/**
1349
+	 * Pass the collection to the given callback and then return it.
1350
+	 *
1351
+	 * @param  callable  $callback
1352
+	 * @return $this
1353
+	 */
1354
+	public function tap(callable $callback)
1355
+	{
1356
+		$callback(new static($this->items));
1357
+
1358
+		return $this;
1359
+	}
1360
+
1361
+	/**
1362
+	 * Transform each item in the collection using a callback.
1363
+	 *
1364
+	 * @param  callable  $callback
1365
+	 * @return $this
1366
+	 */
1367
+	public function transform(callable $callback)
1368
+	{
1369
+		$this->items = $this->map($callback)->all();
1370
+
1371
+		return $this;
1372
+	}
1373
+
1374
+	/**
1375
+	 * Return only unique items from the collection array.
1376
+	 *
1377
+	 * @param  string|callable|null  $key
1378
+	 * @param  bool  $strict
1379
+	 * @return static
1380
+	 */
1381
+	public function unique($key = null, $strict = false)
1382
+	{
1383
+		if (is_null($key)) {
1384
+			return new static(array_unique($this->items, SORT_REGULAR));
1385
+		}
1386
+
1387
+		$callback = $this->valueRetriever($key);
1388
+
1389
+		$exists = [];
1390
+
1391
+		return $this->reject(function ($item, $key) use ($callback, $strict, &$exists) {
1392
+			if (in_array($id = $callback($item, $key), $exists, $strict)) {
1393
+				return true;
1394
+			}
1395
+
1396
+			$exists[] = $id;
1397
+		});
1398
+	}
1399
+
1400
+	/**
1401
+	 * Return only unique items from the collection array using strict comparison.
1402
+	 *
1403
+	 * @param  string|callable|null  $key
1404
+	 * @return static
1405
+	 */
1406
+	public function uniqueStrict($key = null)
1407
+	{
1408
+		return $this->unique($key, true);
1409
+	}
1410
+
1411
+	/**
1412
+	 * Reset the keys on the underlying array.
1413
+	 *
1414
+	 * @return static
1415
+	 */
1416
+	public function values()
1417
+	{
1418
+		return new static(array_values($this->items));
1419
+	}
1420
+
1421
+	/**
1422
+	 * Get a value retrieving callback.
1423
+	 *
1424
+	 * @param  string  $value
1425
+	 * @return callable
1426
+	 */
1427
+	protected function valueRetriever($value)
1428
+	{
1429
+		if ($this->useAsCallable($value)) {
1430
+			return $value;
1431
+		}
1432
+
1433
+		return function ($item) use ($value) {
1434
+			return data_get($item, $value);
1435
+		};
1436
+	}
1437
+
1438
+	/**
1439
+	 * Zip the collection together with one or more arrays.
1440
+	 *
1441
+	 * e.g. new Collection([1, 2, 3])->zip([4, 5, 6]);
1442
+	 *      => [[1, 4], [2, 5], [3, 6]]
1443
+	 *
1444
+	 * @param  mixed ...$items
1445
+	 * @return static
1446
+	 */
1447
+	public function zip($items)
1448
+	{
1449
+		$arrayableItems = array_map(function ($items) {
1450
+			return $this->getArrayableItems($items);
1451
+		}, func_get_args());
1452
+
1453
+		$params = array_merge([function () {
1454
+			return new static(func_get_args());
1455
+		}, $this->items], $arrayableItems);
1456
+
1457
+		return new static(call_user_func_array('array_map', $params));
1458
+	}
1459
+
1460
+	/**
1461
+	 * Get the collection of items as a plain array.
1462
+	 *
1463
+	 * @return array
1464
+	 */
1465
+	public function toArray()
1466
+	{
1467
+		return array_map(function ($value) {
1468
+			return $value instanceof Arrayable ? $value->toArray() : $value;
1469
+		}, $this->items);
1470
+	}
1471
+
1472
+	/**
1473
+	 * Convert the object into something JSON serializable.
1474
+	 *
1475
+	 * @return array
1476
+	 */
1477
+	public function jsonSerialize()
1478
+	{
1479
+		return array_map(function ($value) {
1480
+			if ($value instanceof JsonSerializable) {
1481
+				return $value->jsonSerialize();
1482
+			} elseif ($value instanceof Jsonable) {
1483
+				return json_decode($value->toJson(), true);
1484
+			} elseif ($value instanceof Arrayable) {
1485
+				return $value->toArray();
1486
+			} else {
1487
+				return $value;
1488
+			}
1489
+		}, $this->items);
1490
+	}
1491
+
1492
+	/**
1493
+	 * Get the collection of items as JSON.
1494
+	 *
1495
+	 * @param  int  $options
1496
+	 * @return string
1497
+	 */
1498
+	public function toJson($options = 0)
1499
+	{
1500
+		return json_encode($this->jsonSerialize(), $options);
1501
+	}
1502
+
1503
+	/**
1504
+	 * Get an iterator for the items.
1505
+	 *
1506
+	 * @return \ArrayIterator
1507
+	 */
1508
+	public function getIterator()
1509
+	{
1510
+		return new ArrayIterator($this->items);
1511
+	}
1512
+
1513
+	/**
1514
+	 * Get a CachingIterator instance.
1515
+	 *
1516
+	 * @param  int  $flags
1517
+	 * @return \CachingIterator
1518
+	 */
1519
+	public function getCachingIterator($flags = CachingIterator::CALL_TOSTRING)
1520
+	{
1521
+		return new CachingIterator($this->getIterator(), $flags);
1522
+	}
1523
+
1524
+	/**
1525
+	 * Count the number of items in the collection.
1526
+	 *
1527
+	 * @return int
1528
+	 */
1529
+	public function count()
1530
+	{
1531
+		return count($this->items);
1532
+	}
1533
+
1534
+	/**
1535
+	 * Get a base Support collection instance from this collection.
1536
+	 *
1537
+	 * @return \Illuminate\Support\Collection
1538
+	 */
1539
+	public function toBase()
1540
+	{
1541
+		return new self($this);
1542
+	}
1543
+
1544
+	/**
1545
+	 * Determine if an item exists at an offset.
1546
+	 *
1547
+	 * @param  mixed  $key
1548
+	 * @return bool
1549
+	 */
1550
+	public function offsetExists($key)
1551
+	{
1552
+		return array_key_exists($key, $this->items);
1553
+	}
1554
+
1555
+	/**
1556
+	 * Get an item at a given offset.
1557
+	 *
1558
+	 * @param  mixed  $key
1559
+	 * @return mixed
1560
+	 */
1561
+	public function offsetGet($key)
1562
+	{
1563
+		return $this->items[$key];
1564
+	}
1565
+
1566
+	/**
1567
+	 * Set the item at a given offset.
1568
+	 *
1569
+	 * @param  mixed  $key
1570
+	 * @param  mixed  $value
1571
+	 * @return void
1572
+	 */
1573
+	public function offsetSet($key, $value)
1574
+	{
1575
+		if (is_null($key)) {
1576
+			$this->items[] = $value;
1577
+		} else {
1578
+			$this->items[$key] = $value;
1579
+		}
1580
+	}
1581
+
1582
+	/**
1583
+	 * Unset the item at a given offset.
1584
+	 *
1585
+	 * @param  string  $key
1586
+	 * @return void
1587
+	 */
1588
+	public function offsetUnset($key)
1589
+	{
1590
+		unset($this->items[$key]);
1591
+	}
1592
+
1593
+	/**
1594
+	 * Convert the collection to its string representation.
1595
+	 *
1596
+	 * @return string
1597
+	 */
1598
+	public function __toString()
1599
+	{
1600
+		return $this->toJson();
1601
+	}
1602
+
1603
+	/**
1604
+	 * Results array of items from Collection or Arrayable.
1605
+	 *
1606
+	 * @param  mixed  $items
1607
+	 * @return array
1608
+	 */
1609
+	protected function getArrayableItems($items)
1610
+	{
1611
+		if (is_array($items)) {
1612
+			return $items;
1613
+		} elseif ($items instanceof self) {
1614
+			return $items->all();
1615
+		} elseif ($items instanceof Arrayable) {
1616
+			return $items->toArray();
1617
+		} elseif ($items instanceof Jsonable) {
1618
+			return json_decode($items->toJson(), true);
1619
+		} elseif ($items instanceof JsonSerializable) {
1620
+			return $items->jsonSerialize();
1621
+		} elseif ($items instanceof Traversable) {
1622
+			return iterator_to_array($items);
1623
+		}
1624
+
1625
+		return (array) $items;
1626
+	}
1627
+
1628
+	/**
1629
+	 * Add a method to the list of proxied methods.
1630
+	 *
1631
+	 * @param  string  $method
1632
+	 * @return void
1633
+	 */
1634
+	public static function proxy($method)
1635
+	{
1636
+		static::$proxies[] = $method;
1637
+	}
1638
+
1639
+	/**
1640
+	 * Dynamically access collection proxies.
1641
+	 *
1642
+	 * @param  string  $key
1643
+	 * @return mixed
1644
+	 *
1645
+	 * @throws \Exception
1646
+	 */
1647
+	public function __get($key)
1648
+	{
1649
+		if (! in_array($key, static::$proxies)) {
1650
+			throw new Exception("Property [{$key}] does not exist on this collection instance.");
1651
+		}
1652
+
1653
+		return new HigherOrderCollectionProxy($this, $key);
1654
+	}
1655 1655
 }
Please login to merge, or discard this patch.
Spacing   +365 added lines, -365 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
      *
24 24
      * @var array
25 25
      */
26
-    protected $items = [];
26
+    protected $items = [ ];
27 27
 
28 28
     /**
29 29
      * The methods that can be proxied.
@@ -41,9 +41,9 @@  discard block
 block discarded – undo
41 41
      * @param  mixed  $items
42 42
      * @return void
43 43
      */
44
-    public function __construct($items = [])
44
+    public function __construct( $items = [ ] )
45 45
     {
46
-        $this->items = $this->getArrayableItems($items);
46
+        $this->items = $this->getArrayableItems( $items );
47 47
     }
48 48
 
49 49
     /**
@@ -52,9 +52,9 @@  discard block
 block discarded – undo
52 52
      * @param  mixed  $items
53 53
      * @return static
54 54
      */
55
-    public static function make($items = [])
55
+    public static function make( $items = [ ] )
56 56
     {
57
-        return new static($items);
57
+        return new static( $items );
58 58
     }
59 59
 
60 60
     /**
@@ -64,17 +64,17 @@  discard block
 block discarded – undo
64 64
      * @param  callable  $callback
65 65
      * @return static
66 66
      */
67
-    public static function times($number, callable $callback = null)
67
+    public static function times( $number, callable $callback = null )
68 68
     {
69
-        if ($number < 1) {
69
+        if ( $number < 1 ) {
70 70
             return new static;
71 71
         }
72 72
 
73
-        if (is_null($callback)) {
74
-            return new static(range(1, $number));
73
+        if ( is_null( $callback ) ) {
74
+            return new static( range( 1, $number ) );
75 75
         }
76 76
 
77
-        return (new static(range(1, $number)))->map($callback);
77
+        return ( new static( range( 1, $number ) ) )->map( $callback );
78 78
     }
79 79
 
80 80
     /**
@@ -93,10 +93,10 @@  discard block
 block discarded – undo
93 93
      * @param  callable|string|null  $callback
94 94
      * @return mixed
95 95
      */
96
-    public function avg($callback = null)
96
+    public function avg( $callback = null )
97 97
     {
98
-        if ($count = $this->count()) {
99
-            return $this->sum($callback) / $count;
98
+        if ( $count = $this->count() ) {
99
+            return $this->sum( $callback ) / $count;
100 100
         }
101 101
     }
102 102
 
@@ -106,9 +106,9 @@  discard block
 block discarded – undo
106 106
      * @param  callable|string|null  $callback
107 107
      * @return mixed
108 108
      */
109
-    public function average($callback = null)
109
+    public function average( $callback = null )
110 110
     {
111
-        return $this->avg($callback);
111
+        return $this->avg( $callback );
112 112
     }
113 113
 
114 114
     /**
@@ -117,26 +117,26 @@  discard block
 block discarded – undo
117 117
      * @param  null $key
118 118
      * @return mixed
119 119
      */
120
-    public function median($key = null)
120
+    public function median( $key = null )
121 121
     {
122 122
         $count = $this->count();
123 123
 
124
-        if ($count == 0) {
124
+        if ( $count == 0 ) {
125 125
             return;
126 126
         }
127 127
 
128
-        $values = with(isset($key) ? $this->pluck($key) : $this)
128
+        $values = with( isset( $key ) ? $this->pluck( $key ) : $this )
129 129
                     ->sort()->values();
130 130
 
131
-        $middle = (int) ($count / 2);
131
+        $middle = (int)( $count / 2 );
132 132
 
133
-        if ($count % 2) {
134
-            return $values->get($middle);
133
+        if ( $count % 2 ) {
134
+            return $values->get( $middle );
135 135
         }
136 136
 
137
-        return (new static([
138
-            $values->get($middle - 1), $values->get($middle),
139
-        ]))->average();
137
+        return ( new static( [
138
+            $values->get( $middle - 1 ), $values->get( $middle ),
139
+        ] ) )->average();
140 140
     }
141 141
 
142 142
     /**
@@ -145,27 +145,27 @@  discard block
 block discarded – undo
145 145
      * @param  mixed  $key
146 146
      * @return array|null
147 147
      */
148
-    public function mode($key = null)
148
+    public function mode( $key = null )
149 149
     {
150 150
         $count = $this->count();
151 151
 
152
-        if ($count == 0) {
152
+        if ( $count == 0 ) {
153 153
             return;
154 154
         }
155 155
 
156
-        $collection = isset($key) ? $this->pluck($key) : $this;
156
+        $collection = isset( $key ) ? $this->pluck( $key ) : $this;
157 157
 
158 158
         $counts = new self;
159 159
 
160
-        $collection->each(function ($value) use ($counts) {
161
-            $counts[$value] = isset($counts[$value]) ? $counts[$value] + 1 : 1;
160
+        $collection->each( function( $value ) use ( $counts ) {
161
+            $counts[ $value ] = isset( $counts[ $value ] ) ? $counts[ $value ] + 1 : 1;
162 162
         });
163 163
 
164 164
         $sorted = $counts->sort();
165 165
 
166 166
         $highestValue = $sorted->last();
167 167
 
168
-        return $sorted->filter(function ($value) use ($highestValue) {
168
+        return $sorted->filter( function( $value ) use ( $highestValue ) {
169 169
             return $value == $highestValue;
170 170
         })->sort()->keys()->all();
171 171
     }
@@ -177,7 +177,7 @@  discard block
 block discarded – undo
177 177
      */
178 178
     public function collapse()
179 179
     {
180
-        return new static(Arr::collapse($this->items));
180
+        return new static( Arr::collapse( $this->items ) );
181 181
     }
182 182
 
183 183
     /**
@@ -188,23 +188,23 @@  discard block
 block discarded – undo
188 188
      * @param  mixed  $value
189 189
      * @return bool
190 190
      */
191
-    public function contains($key, $operator = null, $value = null)
191
+    public function contains( $key, $operator = null, $value = null )
192 192
     {
193
-        if (func_num_args() == 1) {
194
-            if ($this->useAsCallable($key)) {
195
-                return ! is_null($this->first($key));
193
+        if ( func_num_args() == 1 ) {
194
+            if ( $this->useAsCallable( $key ) ) {
195
+                return ! is_null( $this->first( $key ) );
196 196
             }
197 197
 
198
-            return in_array($key, $this->items);
198
+            return in_array( $key, $this->items );
199 199
         }
200 200
 
201
-        if (func_num_args() == 2) {
201
+        if ( func_num_args() == 2 ) {
202 202
             $value = $operator;
203 203
 
204 204
             $operator = '=';
205 205
         }
206 206
 
207
-        return $this->contains($this->operatorForWhere($key, $operator, $value));
207
+        return $this->contains( $this->operatorForWhere( $key, $operator, $value ) );
208 208
     }
209 209
 
210 210
     /**
@@ -214,19 +214,19 @@  discard block
 block discarded – undo
214 214
      * @param  mixed  $value
215 215
      * @return bool
216 216
      */
217
-    public function containsStrict($key, $value = null)
217
+    public function containsStrict( $key, $value = null )
218 218
     {
219
-        if (func_num_args() == 2) {
220
-            return $this->contains(function ($item) use ($key, $value) {
221
-                return data_get($item, $key) === $value;
219
+        if ( func_num_args() == 2 ) {
220
+            return $this->contains( function( $item ) use ( $key, $value ) {
221
+                return data_get( $item, $key ) === $value;
222 222
             });
223 223
         }
224 224
 
225
-        if ($this->useAsCallable($key)) {
226
-            return ! is_null($this->first($key));
225
+        if ( $this->useAsCallable( $key ) ) {
226
+            return ! is_null( $this->first( $key ) );
227 227
         }
228 228
 
229
-        return in_array($key, $this->items, true);
229
+        return in_array( $key, $this->items, true );
230 230
     }
231 231
 
232 232
     /**
@@ -235,11 +235,11 @@  discard block
 block discarded – undo
235 235
      * @param  mixed  ...$lists
236 236
      * @return static
237 237
      */
238
-    public function crossJoin(...$lists)
238
+    public function crossJoin( ...$lists )
239 239
     {
240
-        return new static(Arr::crossJoin(
241
-            $this->items, ...array_map([$this, 'getArrayableItems'], $lists)
242
-        ));
240
+        return new static( Arr::crossJoin(
241
+            $this->items, ...array_map( [ $this, 'getArrayableItems' ], $lists )
242
+        ) );
243 243
     }
244 244
 
245 245
     /**
@@ -248,9 +248,9 @@  discard block
 block discarded – undo
248 248
      * @param  mixed  $items
249 249
      * @return static
250 250
      */
251
-    public function diff($items)
251
+    public function diff( $items )
252 252
     {
253
-        return new static(array_diff($this->items, $this->getArrayableItems($items)));
253
+        return new static( array_diff( $this->items, $this->getArrayableItems( $items ) ) );
254 254
     }
255 255
 
256 256
     /**
@@ -259,9 +259,9 @@  discard block
 block discarded – undo
259 259
      * @param  mixed  $items
260 260
      * @return static
261 261
      */
262
-    public function diffAssoc($items)
262
+    public function diffAssoc( $items )
263 263
     {
264
-        return new static(array_diff_assoc($this->items, $this->getArrayableItems($items)));
264
+        return new static( array_diff_assoc( $this->items, $this->getArrayableItems( $items ) ) );
265 265
     }
266 266
 
267 267
     /**
@@ -270,9 +270,9 @@  discard block
 block discarded – undo
270 270
      * @param  mixed  $items
271 271
      * @return static
272 272
      */
273
-    public function diffKeys($items)
273
+    public function diffKeys( $items )
274 274
     {
275
-        return new static(array_diff_key($this->items, $this->getArrayableItems($items)));
275
+        return new static( array_diff_key( $this->items, $this->getArrayableItems( $items ) ) );
276 276
     }
277 277
 
278 278
     /**
@@ -281,10 +281,10 @@  discard block
 block discarded – undo
281 281
      * @param  callable  $callback
282 282
      * @return $this
283 283
      */
284
-    public function each(callable $callback)
284
+    public function each( callable $callback )
285 285
     {
286
-        foreach ($this->items as $key => $item) {
287
-            if ($callback($item, $key) === false) {
286
+        foreach ( $this->items as $key => $item ) {
287
+            if ( $callback( $item, $key ) === false ) {
288 288
                 break;
289 289
             }
290 290
         }
@@ -298,10 +298,10 @@  discard block
 block discarded – undo
298 298
      * @param  callable  $callback
299 299
      * @return static
300 300
      */
301
-    public function eachSpread(callable $callback)
301
+    public function eachSpread( callable $callback )
302 302
     {
303
-        return $this->each(function ($chunk) use ($callback) {
304
-            return $callback(...$chunk);
303
+        return $this->each( function( $chunk ) use ( $callback ) {
304
+            return $callback( ...$chunk );
305 305
         });
306 306
     }
307 307
 
@@ -313,13 +313,13 @@  discard block
 block discarded – undo
313 313
      * @param  mixed  $value
314 314
      * @return bool
315 315
      */
316
-    public function every($key, $operator = null, $value = null)
316
+    public function every( $key, $operator = null, $value = null )
317 317
     {
318
-        if (func_num_args() == 1) {
319
-            $callback = $this->valueRetriever($key);
318
+        if ( func_num_args() == 1 ) {
319
+            $callback = $this->valueRetriever( $key );
320 320
 
321
-            foreach ($this->items as $k => $v) {
322
-                if (! $callback($v, $k)) {
321
+            foreach ( $this->items as $k => $v ) {
322
+                if ( ! $callback( $v, $k ) ) {
323 323
                     return false;
324 324
                 }
325 325
             }
@@ -327,13 +327,13 @@  discard block
 block discarded – undo
327 327
             return true;
328 328
         }
329 329
 
330
-        if (func_num_args() == 2) {
330
+        if ( func_num_args() == 2 ) {
331 331
             $value = $operator;
332 332
 
333 333
             $operator = '=';
334 334
         }
335 335
 
336
-        return $this->every($this->operatorForWhere($key, $operator, $value));
336
+        return $this->every( $this->operatorForWhere( $key, $operator, $value ) );
337 337
     }
338 338
 
339 339
     /**
@@ -342,11 +342,11 @@  discard block
 block discarded – undo
342 342
      * @param  mixed  $keys
343 343
      * @return static
344 344
      */
345
-    public function except($keys)
345
+    public function except( $keys )
346 346
     {
347
-        $keys = is_array($keys) ? $keys : func_get_args();
347
+        $keys = is_array( $keys ) ? $keys : func_get_args();
348 348
 
349
-        return new static(Arr::except($this->items, $keys));
349
+        return new static( Arr::except( $this->items, $keys ) );
350 350
     }
351 351
 
352 352
     /**
@@ -355,13 +355,13 @@  discard block
 block discarded – undo
355 355
      * @param  callable|null  $callback
356 356
      * @return static
357 357
      */
358
-    public function filter(callable $callback = null)
358
+    public function filter( callable $callback = null )
359 359
     {
360
-        if ($callback) {
361
-            return new static(Arr::where($this->items, $callback));
360
+        if ( $callback ) {
361
+            return new static( Arr::where( $this->items, $callback ) );
362 362
         }
363 363
 
364
-        return new static(array_filter($this->items));
364
+        return new static( array_filter( $this->items ) );
365 365
     }
366 366
 
367 367
     /**
@@ -372,12 +372,12 @@  discard block
 block discarded – undo
372 372
      * @param  callable  $default
373 373
      * @return mixed
374 374
      */
375
-    public function when($value, callable $callback, callable $default = null)
375
+    public function when( $value, callable $callback, callable $default = null )
376 376
     {
377
-        if ($value) {
378
-            return $callback($this);
379
-        } elseif ($default) {
380
-            return $default($this);
377
+        if ( $value ) {
378
+            return $callback( $this );
379
+        } elseif ( $default ) {
380
+            return $default( $this );
381 381
         }
382 382
 
383 383
         return $this;
@@ -391,9 +391,9 @@  discard block
 block discarded – undo
391 391
      * @param  callable  $default
392 392
      * @return mixed
393 393
      */
394
-    public function unless($value, callable $callback, callable $default = null)
394
+    public function unless( $value, callable $callback, callable $default = null )
395 395
     {
396
-        return $this->when(! $value, $callback, $default);
396
+        return $this->when( ! $value, $callback, $default );
397 397
     }
398 398
 
399 399
     /**
@@ -404,15 +404,15 @@  discard block
 block discarded – undo
404 404
      * @param  mixed  $value
405 405
      * @return static
406 406
      */
407
-    public function where($key, $operator, $value = null)
407
+    public function where( $key, $operator, $value = null )
408 408
     {
409
-        if (func_num_args() == 2) {
409
+        if ( func_num_args() == 2 ) {
410 410
             $value = $operator;
411 411
 
412 412
             $operator = '=';
413 413
         }
414 414
 
415
-        return $this->filter($this->operatorForWhere($key, $operator, $value));
415
+        return $this->filter( $this->operatorForWhere( $key, $operator, $value ) );
416 416
     }
417 417
 
418 418
     /**
@@ -423,12 +423,12 @@  discard block
 block discarded – undo
423 423
      * @param  mixed  $value
424 424
      * @return \Closure
425 425
      */
426
-    protected function operatorForWhere($key, $operator, $value)
426
+    protected function operatorForWhere( $key, $operator, $value )
427 427
     {
428
-        return function ($item) use ($key, $operator, $value) {
429
-            $retrieved = data_get($item, $key);
428
+        return function( $item ) use ( $key, $operator, $value ) {
429
+            $retrieved = data_get( $item, $key );
430 430
 
431
-            switch ($operator) {
431
+            switch ( $operator ) {
432 432
                 default:
433 433
                 case '=':
434 434
                 case '==':  return $retrieved == $value;
@@ -451,9 +451,9 @@  discard block
 block discarded – undo
451 451
      * @param  mixed  $value
452 452
      * @return static
453 453
      */
454
-    public function whereStrict($key, $value)
454
+    public function whereStrict( $key, $value )
455 455
     {
456
-        return $this->where($key, '===', $value);
456
+        return $this->where( $key, '===', $value );
457 457
     }
458 458
 
459 459
     /**
@@ -464,12 +464,12 @@  discard block
 block discarded – undo
464 464
      * @param  bool  $strict
465 465
      * @return static
466 466
      */
467
-    public function whereIn($key, $values, $strict = false)
467
+    public function whereIn( $key, $values, $strict = false )
468 468
     {
469
-        $values = $this->getArrayableItems($values);
469
+        $values = $this->getArrayableItems( $values );
470 470
 
471
-        return $this->filter(function ($item) use ($key, $values, $strict) {
472
-            return in_array(data_get($item, $key), $values, $strict);
471
+        return $this->filter( function( $item ) use ( $key, $values, $strict ) {
472
+            return in_array( data_get( $item, $key ), $values, $strict );
473 473
         });
474 474
     }
475 475
 
@@ -480,9 +480,9 @@  discard block
 block discarded – undo
480 480
      * @param  mixed  $values
481 481
      * @return static
482 482
      */
483
-    public function whereInStrict($key, $values)
483
+    public function whereInStrict( $key, $values )
484 484
     {
485
-        return $this->whereIn($key, $values, true);
485
+        return $this->whereIn( $key, $values, true );
486 486
     }
487 487
 
488 488
     /**
@@ -493,12 +493,12 @@  discard block
 block discarded – undo
493 493
      * @param  bool  $strict
494 494
      * @return static
495 495
      */
496
-    public function whereNotIn($key, $values, $strict = false)
496
+    public function whereNotIn( $key, $values, $strict = false )
497 497
     {
498
-        $values = $this->getArrayableItems($values);
498
+        $values = $this->getArrayableItems( $values );
499 499
 
500
-        return $this->reject(function ($item) use ($key, $values, $strict) {
501
-            return in_array(data_get($item, $key), $values, $strict);
500
+        return $this->reject( function( $item ) use ( $key, $values, $strict ) {
501
+            return in_array( data_get( $item, $key ), $values, $strict );
502 502
         });
503 503
     }
504 504
 
@@ -509,9 +509,9 @@  discard block
 block discarded – undo
509 509
      * @param  mixed  $values
510 510
      * @return static
511 511
      */
512
-    public function whereNotInStrict($key, $values)
512
+    public function whereNotInStrict( $key, $values )
513 513
     {
514
-        return $this->whereNotIn($key, $values, true);
514
+        return $this->whereNotIn( $key, $values, true );
515 515
     }
516 516
 
517 517
     /**
@@ -521,9 +521,9 @@  discard block
 block discarded – undo
521 521
      * @param  mixed  $default
522 522
      * @return mixed
523 523
      */
524
-    public function first(callable $callback = null, $default = null)
524
+    public function first( callable $callback = null, $default = null )
525 525
     {
526
-        return Arr::first($this->items, $callback, $default);
526
+        return Arr::first( $this->items, $callback, $default );
527 527
     }
528 528
 
529 529
     /**
@@ -532,9 +532,9 @@  discard block
 block discarded – undo
532 532
      * @param  int  $depth
533 533
      * @return static
534 534
      */
535
-    public function flatten($depth = INF)
535
+    public function flatten( $depth = INF )
536 536
     {
537
-        return new static(Arr::flatten($this->items, $depth));
537
+        return new static( Arr::flatten( $this->items, $depth ) );
538 538
     }
539 539
 
540 540
     /**
@@ -544,7 +544,7 @@  discard block
 block discarded – undo
544 544
      */
545 545
     public function flip()
546 546
     {
547
-        return new static(array_flip($this->items));
547
+        return new static( array_flip( $this->items ) );
548 548
     }
549 549
 
550 550
     /**
@@ -553,10 +553,10 @@  discard block
 block discarded – undo
553 553
      * @param  string|array  $keys
554 554
      * @return $this
555 555
      */
556
-    public function forget($keys)
556
+    public function forget( $keys )
557 557
     {
558
-        foreach ((array) $keys as $key) {
559
-            $this->offsetUnset($key);
558
+        foreach ( (array)$keys as $key ) {
559
+            $this->offsetUnset( $key );
560 560
         }
561 561
 
562 562
         return $this;
@@ -569,13 +569,13 @@  discard block
 block discarded – undo
569 569
      * @param  mixed  $default
570 570
      * @return mixed
571 571
      */
572
-    public function get($key, $default = null)
572
+    public function get( $key, $default = null )
573 573
     {
574
-        if ($this->offsetExists($key)) {
575
-            return $this->items[$key];
574
+        if ( $this->offsetExists( $key ) ) {
575
+            return $this->items[ $key ];
576 576
         }
577 577
 
578
-        return value($default);
578
+        return value( $default );
579 579
     }
580 580
 
581 581
     /**
@@ -585,31 +585,31 @@  discard block
 block discarded – undo
585 585
      * @param  bool  $preserveKeys
586 586
      * @return static
587 587
      */
588
-    public function groupBy($groupBy, $preserveKeys = false)
588
+    public function groupBy( $groupBy, $preserveKeys = false )
589 589
     {
590
-        $groupBy = $this->valueRetriever($groupBy);
590
+        $groupBy = $this->valueRetriever( $groupBy );
591 591
 
592
-        $results = [];
592
+        $results = [ ];
593 593
 
594
-        foreach ($this->items as $key => $value) {
595
-            $groupKeys = $groupBy($value, $key);
594
+        foreach ( $this->items as $key => $value ) {
595
+            $groupKeys = $groupBy( $value, $key );
596 596
 
597
-            if (! is_array($groupKeys)) {
598
-                $groupKeys = [$groupKeys];
597
+            if ( ! is_array( $groupKeys ) ) {
598
+                $groupKeys = [ $groupKeys ];
599 599
             }
600 600
 
601
-            foreach ($groupKeys as $groupKey) {
602
-                $groupKey = is_bool($groupKey) ? (int) $groupKey : $groupKey;
601
+            foreach ( $groupKeys as $groupKey ) {
602
+                $groupKey = is_bool( $groupKey ) ? (int)$groupKey : $groupKey;
603 603
 
604
-                if (! array_key_exists($groupKey, $results)) {
605
-                    $results[$groupKey] = new static;
604
+                if ( ! array_key_exists( $groupKey, $results ) ) {
605
+                    $results[ $groupKey ] = new static;
606 606
                 }
607 607
 
608
-                $results[$groupKey]->offsetSet($preserveKeys ? $key : null, $value);
608
+                $results[ $groupKey ]->offsetSet( $preserveKeys ? $key : null, $value );
609 609
             }
610 610
         }
611 611
 
612
-        return new static($results);
612
+        return new static( $results );
613 613
     }
614 614
 
615 615
     /**
@@ -618,23 +618,23 @@  discard block
 block discarded – undo
618 618
      * @param  callable|string  $keyBy
619 619
      * @return static
620 620
      */
621
-    public function keyBy($keyBy)
621
+    public function keyBy( $keyBy )
622 622
     {
623
-        $keyBy = $this->valueRetriever($keyBy);
623
+        $keyBy = $this->valueRetriever( $keyBy );
624 624
 
625
-        $results = [];
625
+        $results = [ ];
626 626
 
627
-        foreach ($this->items as $key => $item) {
628
-            $resolvedKey = $keyBy($item, $key);
627
+        foreach ( $this->items as $key => $item ) {
628
+            $resolvedKey = $keyBy( $item, $key );
629 629
 
630
-            if (is_object($resolvedKey)) {
631
-                $resolvedKey = (string) $resolvedKey;
630
+            if ( is_object( $resolvedKey ) ) {
631
+                $resolvedKey = (string)$resolvedKey;
632 632
             }
633 633
 
634
-            $results[$resolvedKey] = $item;
634
+            $results[ $resolvedKey ] = $item;
635 635
         }
636 636
 
637
-        return new static($results);
637
+        return new static( $results );
638 638
     }
639 639
 
640 640
     /**
@@ -643,9 +643,9 @@  discard block
 block discarded – undo
643 643
      * @param  mixed  $key
644 644
      * @return bool
645 645
      */
646
-    public function has($key)
646
+    public function has( $key )
647 647
     {
648
-        return $this->offsetExists($key);
648
+        return $this->offsetExists( $key );
649 649
     }
650 650
 
651 651
     /**
@@ -655,15 +655,15 @@  discard block
 block discarded – undo
655 655
      * @param  string  $glue
656 656
      * @return string
657 657
      */
658
-    public function implode($value, $glue = null)
658
+    public function implode( $value, $glue = null )
659 659
     {
660 660
         $first = $this->first();
661 661
 
662
-        if (is_array($first) || is_object($first)) {
663
-            return implode($glue, $this->pluck($value)->all());
662
+        if ( is_array( $first ) || is_object( $first ) ) {
663
+            return implode( $glue, $this->pluck( $value )->all() );
664 664
         }
665 665
 
666
-        return implode($value, $this->items);
666
+        return implode( $value, $this->items );
667 667
     }
668 668
 
669 669
     /**
@@ -672,9 +672,9 @@  discard block
 block discarded – undo
672 672
      * @param  mixed  $items
673 673
      * @return static
674 674
      */
675
-    public function intersect($items)
675
+    public function intersect( $items )
676 676
     {
677
-        return new static(array_intersect($this->items, $this->getArrayableItems($items)));
677
+        return new static( array_intersect( $this->items, $this->getArrayableItems( $items ) ) );
678 678
     }
679 679
 
680 680
     /**
@@ -683,9 +683,9 @@  discard block
 block discarded – undo
683 683
      * @param  mixed  $items
684 684
      * @return static
685 685
      */
686
-    public function intersectKey($items)
686
+    public function intersectKey( $items )
687 687
     {
688
-        return new static(array_intersect_key($this->items, $this->getArrayableItems($items)));
688
+        return new static( array_intersect_key( $this->items, $this->getArrayableItems( $items ) ) );
689 689
     }
690 690
 
691 691
     /**
@@ -695,7 +695,7 @@  discard block
 block discarded – undo
695 695
      */
696 696
     public function isEmpty()
697 697
     {
698
-        return empty($this->items);
698
+        return empty( $this->items );
699 699
     }
700 700
 
701 701
     /**
@@ -714,9 +714,9 @@  discard block
 block discarded – undo
714 714
      * @param  mixed  $value
715 715
      * @return bool
716 716
      */
717
-    protected function useAsCallable($value)
717
+    protected function useAsCallable( $value )
718 718
     {
719
-        return ! is_string($value) && is_callable($value);
719
+        return ! is_string( $value ) && is_callable( $value );
720 720
     }
721 721
 
722 722
     /**
@@ -726,7 +726,7 @@  discard block
 block discarded – undo
726 726
      */
727 727
     public function keys()
728 728
     {
729
-        return new static(array_keys($this->items));
729
+        return new static( array_keys( $this->items ) );
730 730
     }
731 731
 
732 732
     /**
@@ -736,9 +736,9 @@  discard block
 block discarded – undo
736 736
      * @param  mixed  $default
737 737
      * @return mixed
738 738
      */
739
-    public function last(callable $callback = null, $default = null)
739
+    public function last( callable $callback = null, $default = null )
740 740
     {
741
-        return Arr::last($this->items, $callback, $default);
741
+        return Arr::last( $this->items, $callback, $default );
742 742
     }
743 743
 
744 744
     /**
@@ -748,9 +748,9 @@  discard block
 block discarded – undo
748 748
      * @param  string|null  $key
749 749
      * @return static
750 750
      */
751
-    public function pluck($value, $key = null)
751
+    public function pluck( $value, $key = null )
752 752
     {
753
-        return new static(Arr::pluck($this->items, $value, $key));
753
+        return new static( Arr::pluck( $this->items, $value, $key ) );
754 754
     }
755 755
 
756 756
     /**
@@ -759,13 +759,13 @@  discard block
 block discarded – undo
759 759
      * @param  callable  $callback
760 760
      * @return static
761 761
      */
762
-    public function map(callable $callback)
762
+    public function map( callable $callback )
763 763
     {
764
-        $keys = array_keys($this->items);
764
+        $keys = array_keys( $this->items );
765 765
 
766
-        $items = array_map($callback, $this->items, $keys);
766
+        $items = array_map( $callback, $this->items, $keys );
767 767
 
768
-        return new static(array_combine($keys, $items));
768
+        return new static( array_combine( $keys, $items ) );
769 769
     }
770 770
 
771 771
     /**
@@ -774,10 +774,10 @@  discard block
 block discarded – undo
774 774
      * @param  callable  $callback
775 775
      * @return static
776 776
      */
777
-    public function mapSpread(callable $callback)
777
+    public function mapSpread( callable $callback )
778 778
     {
779
-        return $this->map(function ($chunk) use ($callback) {
780
-            return $callback(...$chunk);
779
+        return $this->map( function( $chunk ) use ( $callback ) {
780
+            return $callback( ...$chunk );
781 781
         });
782 782
     }
783 783
 
@@ -789,15 +789,15 @@  discard block
 block discarded – undo
789 789
      * @param  callable  $callback
790 790
      * @return static
791 791
      */
792
-    public function mapToGroups(callable $callback)
792
+    public function mapToGroups( callable $callback )
793 793
     {
794
-        $groups = $this->map($callback)->reduce(function ($groups, $pair) {
795
-            $groups[key($pair)][] = reset($pair);
794
+        $groups = $this->map( $callback )->reduce( function( $groups, $pair ) {
795
+            $groups[ key( $pair ) ][ ] = reset( $pair );
796 796
 
797 797
             return $groups;
798
-        }, []);
798
+        }, [ ] );
799 799
 
800
-        return (new static($groups))->map([$this, 'make']);
800
+        return ( new static( $groups ) )->map( [ $this, 'make' ] );
801 801
     }
802 802
 
803 803
     /**
@@ -808,19 +808,19 @@  discard block
 block discarded – undo
808 808
      * @param  callable  $callback
809 809
      * @return static
810 810
      */
811
-    public function mapWithKeys(callable $callback)
811
+    public function mapWithKeys( callable $callback )
812 812
     {
813
-        $result = [];
813
+        $result = [ ];
814 814
 
815
-        foreach ($this->items as $key => $value) {
816
-            $assoc = $callback($value, $key);
815
+        foreach ( $this->items as $key => $value ) {
816
+            $assoc = $callback( $value, $key );
817 817
 
818
-            foreach ($assoc as $mapKey => $mapValue) {
819
-                $result[$mapKey] = $mapValue;
818
+            foreach ( $assoc as $mapKey => $mapValue ) {
819
+                $result[ $mapKey ] = $mapValue;
820 820
             }
821 821
         }
822 822
 
823
-        return new static($result);
823
+        return new static( $result );
824 824
     }
825 825
 
826 826
     /**
@@ -829,9 +829,9 @@  discard block
 block discarded – undo
829 829
      * @param  callable  $callback
830 830
      * @return static
831 831
      */
832
-    public function flatMap(callable $callback)
832
+    public function flatMap( callable $callback )
833 833
     {
834
-        return $this->map($callback)->collapse();
834
+        return $this->map( $callback )->collapse();
835 835
     }
836 836
 
837 837
     /**
@@ -840,16 +840,16 @@  discard block
 block discarded – undo
840 840
      * @param  callable|string|null  $callback
841 841
      * @return mixed
842 842
      */
843
-    public function max($callback = null)
843
+    public function max( $callback = null )
844 844
     {
845
-        $callback = $this->valueRetriever($callback);
845
+        $callback = $this->valueRetriever( $callback );
846 846
 
847
-        return $this->filter(function ($value) {
848
-            return ! is_null($value);
849
-        })->reduce(function ($result, $item) use ($callback) {
850
-            $value = $callback($item);
847
+        return $this->filter( function( $value ) {
848
+            return ! is_null( $value );
849
+        })->reduce( function( $result, $item ) use ( $callback ) {
850
+            $value = $callback( $item );
851 851
 
852
-            return is_null($result) || $value > $result ? $value : $result;
852
+            return is_null( $result ) || $value > $result ? $value : $result;
853 853
         });
854 854
     }
855 855
 
@@ -859,9 +859,9 @@  discard block
 block discarded – undo
859 859
      * @param  mixed  $items
860 860
      * @return static
861 861
      */
862
-    public function merge($items)
862
+    public function merge( $items )
863 863
     {
864
-        return new static(array_merge($this->items, $this->getArrayableItems($items)));
864
+        return new static( array_merge( $this->items, $this->getArrayableItems( $items ) ) );
865 865
     }
866 866
 
867 867
     /**
@@ -870,9 +870,9 @@  discard block
 block discarded – undo
870 870
      * @param  mixed  $values
871 871
      * @return static
872 872
      */
873
-    public function combine($values)
873
+    public function combine( $values )
874 874
     {
875
-        return new static(array_combine($this->all(), $this->getArrayableItems($values)));
875
+        return new static( array_combine( $this->all(), $this->getArrayableItems( $values ) ) );
876 876
     }
877 877
 
878 878
     /**
@@ -881,9 +881,9 @@  discard block
 block discarded – undo
881 881
      * @param  mixed  $items
882 882
      * @return static
883 883
      */
884
-    public function union($items)
884
+    public function union( $items )
885 885
     {
886
-        return new static($this->items + $this->getArrayableItems($items));
886
+        return new static( $this->items + $this->getArrayableItems( $items ) );
887 887
     }
888 888
 
889 889
     /**
@@ -892,16 +892,16 @@  discard block
 block discarded – undo
892 892
      * @param  callable|string|null  $callback
893 893
      * @return mixed
894 894
      */
895
-    public function min($callback = null)
895
+    public function min( $callback = null )
896 896
     {
897
-        $callback = $this->valueRetriever($callback);
897
+        $callback = $this->valueRetriever( $callback );
898 898
 
899
-        return $this->filter(function ($value) {
900
-            return ! is_null($value);
901
-        })->reduce(function ($result, $item) use ($callback) {
902
-            $value = $callback($item);
899
+        return $this->filter( function( $value ) {
900
+            return ! is_null( $value );
901
+        })->reduce( function( $result, $item ) use ( $callback ) {
902
+            $value = $callback( $item );
903 903
 
904
-            return is_null($result) || $value < $result ? $value : $result;
904
+            return is_null( $result ) || $value < $result ? $value : $result;
905 905
         });
906 906
     }
907 907
 
@@ -912,21 +912,21 @@  discard block
 block discarded – undo
912 912
      * @param  int  $offset
913 913
      * @return static
914 914
      */
915
-    public function nth($step, $offset = 0)
915
+    public function nth( $step, $offset = 0 )
916 916
     {
917
-        $new = [];
917
+        $new = [ ];
918 918
 
919 919
         $position = 0;
920 920
 
921
-        foreach ($this->items as $item) {
922
-            if ($position % $step === $offset) {
923
-                $new[] = $item;
921
+        foreach ( $this->items as $item ) {
922
+            if ( $position % $step === $offset ) {
923
+                $new[ ] = $item;
924 924
             }
925 925
 
926 926
             $position++;
927 927
         }
928 928
 
929
-        return new static($new);
929
+        return new static( $new );
930 930
     }
931 931
 
932 932
     /**
@@ -935,15 +935,15 @@  discard block
 block discarded – undo
935 935
      * @param  mixed  $keys
936 936
      * @return static
937 937
      */
938
-    public function only($keys)
938
+    public function only( $keys )
939 939
     {
940
-        if (is_null($keys)) {
941
-            return new static($this->items);
940
+        if ( is_null( $keys ) ) {
941
+            return new static( $this->items );
942 942
         }
943 943
 
944
-        $keys = is_array($keys) ? $keys : func_get_args();
944
+        $keys = is_array( $keys ) ? $keys : func_get_args();
945 945
 
946
-        return new static(Arr::only($this->items, $keys));
946
+        return new static( Arr::only( $this->items, $keys ) );
947 947
     }
948 948
 
949 949
     /**
@@ -953,9 +953,9 @@  discard block
 block discarded – undo
953 953
      * @param  int  $perPage
954 954
      * @return static
955 955
      */
956
-    public function forPage($page, $perPage)
956
+    public function forPage( $page, $perPage )
957 957
     {
958
-        return $this->slice(($page - 1) * $perPage, $perPage);
958
+        return $this->slice( ( $page - 1 ) * $perPage, $perPage );
959 959
     }
960 960
 
961 961
     /**
@@ -964,17 +964,17 @@  discard block
 block discarded – undo
964 964
      * @param  callable|string  $callback
965 965
      * @return static
966 966
      */
967
-    public function partition($callback)
967
+    public function partition( $callback )
968 968
     {
969
-        $partitions = [new static, new static];
969
+        $partitions = [ new static, new static ];
970 970
 
971
-        $callback = $this->valueRetriever($callback);
971
+        $callback = $this->valueRetriever( $callback );
972 972
 
973
-        foreach ($this->items as $key => $item) {
974
-            $partitions[(int) ! $callback($item)][$key] = $item;
973
+        foreach ( $this->items as $key => $item ) {
974
+            $partitions[ (int)! $callback( $item ) ][ $key ] = $item;
975 975
         }
976 976
 
977
-        return new static($partitions);
977
+        return new static( $partitions );
978 978
     }
979 979
 
980 980
     /**
@@ -983,9 +983,9 @@  discard block
 block discarded – undo
983 983
      * @param  callable $callback
984 984
      * @return mixed
985 985
      */
986
-    public function pipe(callable $callback)
986
+    public function pipe( callable $callback )
987 987
     {
988
-        return $callback($this);
988
+        return $callback( $this );
989 989
     }
990 990
 
991 991
     /**
@@ -995,7 +995,7 @@  discard block
 block discarded – undo
995 995
      */
996 996
     public function pop()
997 997
     {
998
-        return array_pop($this->items);
998
+        return array_pop( $this->items );
999 999
     }
1000 1000
 
1001 1001
     /**
@@ -1005,9 +1005,9 @@  discard block
 block discarded – undo
1005 1005
      * @param  mixed  $key
1006 1006
      * @return $this
1007 1007
      */
1008
-    public function prepend($value, $key = null)
1008
+    public function prepend( $value, $key = null )
1009 1009
     {
1010
-        $this->items = Arr::prepend($this->items, $value, $key);
1010
+        $this->items = Arr::prepend( $this->items, $value, $key );
1011 1011
 
1012 1012
         return $this;
1013 1013
     }
@@ -1018,9 +1018,9 @@  discard block
 block discarded – undo
1018 1018
      * @param  mixed  $value
1019 1019
      * @return $this
1020 1020
      */
1021
-    public function push($value)
1021
+    public function push( $value )
1022 1022
     {
1023
-        $this->offsetSet(null, $value);
1023
+        $this->offsetSet( null, $value );
1024 1024
 
1025 1025
         return $this;
1026 1026
     }
@@ -1031,12 +1031,12 @@  discard block
 block discarded – undo
1031 1031
      * @param  \Traversable  $source
1032 1032
      * @return self
1033 1033
      */
1034
-    public function concat($source)
1034
+    public function concat( $source )
1035 1035
     {
1036
-        $result = new static($this);
1036
+        $result = new static( $this );
1037 1037
 
1038
-        foreach ($source as $item) {
1039
-            $result->push($item);
1038
+        foreach ( $source as $item ) {
1039
+            $result->push( $item );
1040 1040
         }
1041 1041
 
1042 1042
         return $result;
@@ -1049,9 +1049,9 @@  discard block
 block discarded – undo
1049 1049
      * @param  mixed  $default
1050 1050
      * @return mixed
1051 1051
      */
1052
-    public function pull($key, $default = null)
1052
+    public function pull( $key, $default = null )
1053 1053
     {
1054
-        return Arr::pull($this->items, $key, $default);
1054
+        return Arr::pull( $this->items, $key, $default );
1055 1055
     }
1056 1056
 
1057 1057
     /**
@@ -1061,9 +1061,9 @@  discard block
 block discarded – undo
1061 1061
      * @param  mixed  $value
1062 1062
      * @return $this
1063 1063
      */
1064
-    public function put($key, $value)
1064
+    public function put( $key, $value )
1065 1065
     {
1066
-        $this->offsetSet($key, $value);
1066
+        $this->offsetSet( $key, $value );
1067 1067
 
1068 1068
         return $this;
1069 1069
     }
@@ -1076,13 +1076,13 @@  discard block
 block discarded – undo
1076 1076
      *
1077 1077
      * @throws \InvalidArgumentException
1078 1078
      */
1079
-    public function random($number = null)
1079
+    public function random( $number = null )
1080 1080
     {
1081
-        if (is_null($number)) {
1082
-            return Arr::random($this->items);
1081
+        if ( is_null( $number ) ) {
1082
+            return Arr::random( $this->items );
1083 1083
         }
1084 1084
 
1085
-        return new static(Arr::random($this->items, $number));
1085
+        return new static( Arr::random( $this->items, $number ) );
1086 1086
     }
1087 1087
 
1088 1088
     /**
@@ -1092,9 +1092,9 @@  discard block
 block discarded – undo
1092 1092
      * @param  mixed  $initial
1093 1093
      * @return mixed
1094 1094
      */
1095
-    public function reduce(callable $callback, $initial = null)
1095
+    public function reduce( callable $callback, $initial = null )
1096 1096
     {
1097
-        return array_reduce($this->items, $callback, $initial);
1097
+        return array_reduce( $this->items, $callback, $initial );
1098 1098
     }
1099 1099
 
1100 1100
     /**
@@ -1103,15 +1103,15 @@  discard block
 block discarded – undo
1103 1103
      * @param  callable|mixed  $callback
1104 1104
      * @return static
1105 1105
      */
1106
-    public function reject($callback)
1106
+    public function reject( $callback )
1107 1107
     {
1108
-        if ($this->useAsCallable($callback)) {
1109
-            return $this->filter(function ($value, $key) use ($callback) {
1110
-                return ! $callback($value, $key);
1108
+        if ( $this->useAsCallable( $callback ) ) {
1109
+            return $this->filter( function( $value, $key ) use ( $callback ) {
1110
+                return ! $callback( $value, $key );
1111 1111
             });
1112 1112
         }
1113 1113
 
1114
-        return $this->filter(function ($item) use ($callback) {
1114
+        return $this->filter( function( $item ) use ( $callback ) {
1115 1115
             return $item != $callback;
1116 1116
         });
1117 1117
     }
@@ -1123,7 +1123,7 @@  discard block
 block discarded – undo
1123 1123
      */
1124 1124
     public function reverse()
1125 1125
     {
1126
-        return new static(array_reverse($this->items, true));
1126
+        return new static( array_reverse( $this->items, true ) );
1127 1127
     }
1128 1128
 
1129 1129
     /**
@@ -1133,14 +1133,14 @@  discard block
 block discarded – undo
1133 1133
      * @param  bool  $strict
1134 1134
      * @return mixed
1135 1135
      */
1136
-    public function search($value, $strict = false)
1136
+    public function search( $value, $strict = false )
1137 1137
     {
1138
-        if (! $this->useAsCallable($value)) {
1139
-            return array_search($value, $this->items, $strict);
1138
+        if ( ! $this->useAsCallable( $value ) ) {
1139
+            return array_search( $value, $this->items, $strict );
1140 1140
         }
1141 1141
 
1142
-        foreach ($this->items as $key => $item) {
1143
-            if (call_user_func($value, $item, $key)) {
1142
+        foreach ( $this->items as $key => $item ) {
1143
+            if ( call_user_func( $value, $item, $key ) ) {
1144 1144
                 return $key;
1145 1145
             }
1146 1146
         }
@@ -1155,7 +1155,7 @@  discard block
 block discarded – undo
1155 1155
      */
1156 1156
     public function shift()
1157 1157
     {
1158
-        return array_shift($this->items);
1158
+        return array_shift( $this->items );
1159 1159
     }
1160 1160
 
1161 1161
     /**
@@ -1164,21 +1164,21 @@  discard block
 block discarded – undo
1164 1164
      * @param  int  $seed
1165 1165
      * @return static
1166 1166
      */
1167
-    public function shuffle($seed = null)
1167
+    public function shuffle( $seed = null )
1168 1168
     {
1169 1169
         $items = $this->items;
1170 1170
 
1171
-        if (is_null($seed)) {
1172
-            shuffle($items);
1171
+        if ( is_null( $seed ) ) {
1172
+            shuffle( $items );
1173 1173
         } else {
1174
-            srand($seed);
1174
+            srand( $seed );
1175 1175
 
1176
-            usort($items, function () {
1176
+            usort( $items, function() {
1177 1177
                 return rand(-1, 1);
1178 1178
             });
1179 1179
         }
1180 1180
 
1181
-        return new static($items);
1181
+        return new static( $items );
1182 1182
     }
1183 1183
 
1184 1184
     /**
@@ -1188,9 +1188,9 @@  discard block
 block discarded – undo
1188 1188
      * @param  int  $length
1189 1189
      * @return static
1190 1190
      */
1191
-    public function slice($offset, $length = null)
1191
+    public function slice( $offset, $length = null )
1192 1192
     {
1193
-        return new static(array_slice($this->items, $offset, $length, true));
1193
+        return new static( array_slice( $this->items, $offset, $length, true ) );
1194 1194
     }
1195 1195
 
1196 1196
     /**
@@ -1199,15 +1199,15 @@  discard block
 block discarded – undo
1199 1199
      * @param  int  $numberOfGroups
1200 1200
      * @return static
1201 1201
      */
1202
-    public function split($numberOfGroups)
1202
+    public function split( $numberOfGroups )
1203 1203
     {
1204
-        if ($this->isEmpty()) {
1204
+        if ( $this->isEmpty() ) {
1205 1205
             return new static;
1206 1206
         }
1207 1207
 
1208
-        $groupSize = ceil($this->count() / $numberOfGroups);
1208
+        $groupSize = ceil( $this->count() / $numberOfGroups );
1209 1209
 
1210
-        return $this->chunk($groupSize);
1210
+        return $this->chunk( $groupSize );
1211 1211
     }
1212 1212
 
1213 1213
     /**
@@ -1216,19 +1216,19 @@  discard block
 block discarded – undo
1216 1216
      * @param  int  $size
1217 1217
      * @return static
1218 1218
      */
1219
-    public function chunk($size)
1219
+    public function chunk( $size )
1220 1220
     {
1221
-        if ($size <= 0) {
1221
+        if ( $size <= 0 ) {
1222 1222
             return new static;
1223 1223
         }
1224 1224
 
1225
-        $chunks = [];
1225
+        $chunks = [ ];
1226 1226
 
1227
-        foreach (array_chunk($this->items, $size, true) as $chunk) {
1228
-            $chunks[] = new static($chunk);
1227
+        foreach ( array_chunk( $this->items, $size, true ) as $chunk ) {
1228
+            $chunks[ ] = new static( $chunk );
1229 1229
         }
1230 1230
 
1231
-        return new static($chunks);
1231
+        return new static( $chunks );
1232 1232
     }
1233 1233
 
1234 1234
     /**
@@ -1237,15 +1237,15 @@  discard block
 block discarded – undo
1237 1237
      * @param  callable|null  $callback
1238 1238
      * @return static
1239 1239
      */
1240
-    public function sort(callable $callback = null)
1240
+    public function sort( callable $callback = null )
1241 1241
     {
1242 1242
         $items = $this->items;
1243 1243
 
1244 1244
         $callback
1245
-            ? uasort($items, $callback)
1246
-            : asort($items);
1245
+            ? uasort( $items, $callback )
1246
+            : asort( $items );
1247 1247
 
1248
-        return new static($items);
1248
+        return new static( $items );
1249 1249
     }
1250 1250
 
1251 1251
     /**
@@ -1256,30 +1256,30 @@  discard block
 block discarded – undo
1256 1256
      * @param  bool  $descending
1257 1257
      * @return static
1258 1258
      */
1259
-    public function sortBy($callback, $options = SORT_REGULAR, $descending = false)
1259
+    public function sortBy( $callback, $options = SORT_REGULAR, $descending = false )
1260 1260
     {
1261
-        $results = [];
1261
+        $results = [ ];
1262 1262
 
1263
-        $callback = $this->valueRetriever($callback);
1263
+        $callback = $this->valueRetriever( $callback );
1264 1264
 
1265 1265
         // First we will loop through the items and get the comparator from a callback
1266 1266
         // function which we were given. Then, we will sort the returned values and
1267 1267
         // and grab the corresponding values for the sorted keys from this array.
1268
-        foreach ($this->items as $key => $value) {
1269
-            $results[$key] = $callback($value, $key);
1268
+        foreach ( $this->items as $key => $value ) {
1269
+            $results[ $key ] = $callback( $value, $key );
1270 1270
         }
1271 1271
 
1272
-        $descending ? arsort($results, $options)
1273
-                    : asort($results, $options);
1272
+        $descending ? arsort( $results, $options )
1273
+                    : asort( $results, $options );
1274 1274
 
1275 1275
         // Once we have sorted all of the keys in the array, we will loop through them
1276 1276
         // and grab the corresponding model so we can set the underlying items list
1277 1277
         // to the sorted version. Then we'll just return the collection instance.
1278
-        foreach (array_keys($results) as $key) {
1279
-            $results[$key] = $this->items[$key];
1278
+        foreach ( array_keys( $results ) as $key ) {
1279
+            $results[ $key ] = $this->items[ $key ];
1280 1280
         }
1281 1281
 
1282
-        return new static($results);
1282
+        return new static( $results );
1283 1283
     }
1284 1284
 
1285 1285
     /**
@@ -1289,9 +1289,9 @@  discard block
 block discarded – undo
1289 1289
      * @param  int  $options
1290 1290
      * @return static
1291 1291
      */
1292
-    public function sortByDesc($callback, $options = SORT_REGULAR)
1292
+    public function sortByDesc( $callback, $options = SORT_REGULAR )
1293 1293
     {
1294
-        return $this->sortBy($callback, $options, true);
1294
+        return $this->sortBy( $callback, $options, true );
1295 1295
     }
1296 1296
 
1297 1297
     /**
@@ -1302,13 +1302,13 @@  discard block
 block discarded – undo
1302 1302
      * @param  mixed  $replacement
1303 1303
      * @return static
1304 1304
      */
1305
-    public function splice($offset, $length = null, $replacement = [])
1305
+    public function splice( $offset, $length = null, $replacement = [ ] )
1306 1306
     {
1307
-        if (func_num_args() == 1) {
1308
-            return new static(array_splice($this->items, $offset));
1307
+        if ( func_num_args() == 1 ) {
1308
+            return new static( array_splice( $this->items, $offset ) );
1309 1309
         }
1310 1310
 
1311
-        return new static(array_splice($this->items, $offset, $length, $replacement));
1311
+        return new static( array_splice( $this->items, $offset, $length, $replacement ) );
1312 1312
     }
1313 1313
 
1314 1314
     /**
@@ -1317,17 +1317,17 @@  discard block
 block discarded – undo
1317 1317
      * @param  callable|string|null  $callback
1318 1318
      * @return mixed
1319 1319
      */
1320
-    public function sum($callback = null)
1320
+    public function sum( $callback = null )
1321 1321
     {
1322
-        if (is_null($callback)) {
1323
-            return array_sum($this->items);
1322
+        if ( is_null( $callback ) ) {
1323
+            return array_sum( $this->items );
1324 1324
         }
1325 1325
 
1326
-        $callback = $this->valueRetriever($callback);
1326
+        $callback = $this->valueRetriever( $callback );
1327 1327
 
1328
-        return $this->reduce(function ($result, $item) use ($callback) {
1329
-            return $result + $callback($item);
1330
-        }, 0);
1328
+        return $this->reduce( function( $result, $item ) use ( $callback ) {
1329
+            return $result + $callback( $item );
1330
+        }, 0 );
1331 1331
     }
1332 1332
 
1333 1333
     /**
@@ -1336,13 +1336,13 @@  discard block
 block discarded – undo
1336 1336
      * @param  int  $limit
1337 1337
      * @return static
1338 1338
      */
1339
-    public function take($limit)
1339
+    public function take( $limit )
1340 1340
     {
1341
-        if ($limit < 0) {
1342
-            return $this->slice($limit, abs($limit));
1341
+        if ( $limit < 0 ) {
1342
+            return $this->slice( $limit, abs( $limit ) );
1343 1343
         }
1344 1344
 
1345
-        return $this->slice(0, $limit);
1345
+        return $this->slice( 0, $limit );
1346 1346
     }
1347 1347
 
1348 1348
     /**
@@ -1351,9 +1351,9 @@  discard block
 block discarded – undo
1351 1351
      * @param  callable  $callback
1352 1352
      * @return $this
1353 1353
      */
1354
-    public function tap(callable $callback)
1354
+    public function tap( callable $callback )
1355 1355
     {
1356
-        $callback(new static($this->items));
1356
+        $callback( new static( $this->items ) );
1357 1357
 
1358 1358
         return $this;
1359 1359
     }
@@ -1364,9 +1364,9 @@  discard block
 block discarded – undo
1364 1364
      * @param  callable  $callback
1365 1365
      * @return $this
1366 1366
      */
1367
-    public function transform(callable $callback)
1367
+    public function transform( callable $callback )
1368 1368
     {
1369
-        $this->items = $this->map($callback)->all();
1369
+        $this->items = $this->map( $callback )->all();
1370 1370
 
1371 1371
         return $this;
1372 1372
     }
@@ -1378,22 +1378,22 @@  discard block
 block discarded – undo
1378 1378
      * @param  bool  $strict
1379 1379
      * @return static
1380 1380
      */
1381
-    public function unique($key = null, $strict = false)
1381
+    public function unique( $key = null, $strict = false )
1382 1382
     {
1383
-        if (is_null($key)) {
1384
-            return new static(array_unique($this->items, SORT_REGULAR));
1383
+        if ( is_null( $key ) ) {
1384
+            return new static( array_unique( $this->items, SORT_REGULAR ) );
1385 1385
         }
1386 1386
 
1387
-        $callback = $this->valueRetriever($key);
1387
+        $callback = $this->valueRetriever( $key );
1388 1388
 
1389
-        $exists = [];
1389
+        $exists = [ ];
1390 1390
 
1391
-        return $this->reject(function ($item, $key) use ($callback, $strict, &$exists) {
1392
-            if (in_array($id = $callback($item, $key), $exists, $strict)) {
1391
+        return $this->reject( function( $item, $key ) use ( $callback, $strict, &$exists ) {
1392
+            if ( in_array( $id = $callback( $item, $key ), $exists, $strict ) ) {
1393 1393
                 return true;
1394 1394
             }
1395 1395
 
1396
-            $exists[] = $id;
1396
+            $exists[ ] = $id;
1397 1397
         });
1398 1398
     }
1399 1399
 
@@ -1403,9 +1403,9 @@  discard block
 block discarded – undo
1403 1403
      * @param  string|callable|null  $key
1404 1404
      * @return static
1405 1405
      */
1406
-    public function uniqueStrict($key = null)
1406
+    public function uniqueStrict( $key = null )
1407 1407
     {
1408
-        return $this->unique($key, true);
1408
+        return $this->unique( $key, true );
1409 1409
     }
1410 1410
 
1411 1411
     /**
@@ -1415,7 +1415,7 @@  discard block
 block discarded – undo
1415 1415
      */
1416 1416
     public function values()
1417 1417
     {
1418
-        return new static(array_values($this->items));
1418
+        return new static( array_values( $this->items ) );
1419 1419
     }
1420 1420
 
1421 1421
     /**
@@ -1424,14 +1424,14 @@  discard block
 block discarded – undo
1424 1424
      * @param  string  $value
1425 1425
      * @return callable
1426 1426
      */
1427
-    protected function valueRetriever($value)
1427
+    protected function valueRetriever( $value )
1428 1428
     {
1429
-        if ($this->useAsCallable($value)) {
1429
+        if ( $this->useAsCallable( $value ) ) {
1430 1430
             return $value;
1431 1431
         }
1432 1432
 
1433
-        return function ($item) use ($value) {
1434
-            return data_get($item, $value);
1433
+        return function( $item ) use ( $value ) {
1434
+            return data_get( $item, $value );
1435 1435
         };
1436 1436
     }
1437 1437
 
@@ -1444,17 +1444,17 @@  discard block
 block discarded – undo
1444 1444
      * @param  mixed ...$items
1445 1445
      * @return static
1446 1446
      */
1447
-    public function zip($items)
1447
+    public function zip( $items )
1448 1448
     {
1449
-        $arrayableItems = array_map(function ($items) {
1450
-            return $this->getArrayableItems($items);
1451
-        }, func_get_args());
1449
+        $arrayableItems = array_map( function( $items ) {
1450
+            return $this->getArrayableItems( $items );
1451
+        }, func_get_args() );
1452 1452
 
1453
-        $params = array_merge([function () {
1454
-            return new static(func_get_args());
1455
-        }, $this->items], $arrayableItems);
1453
+        $params = array_merge( [ function() {
1454
+            return new static( func_get_args() );
1455
+        }, $this->items ], $arrayableItems );
1456 1456
 
1457
-        return new static(call_user_func_array('array_map', $params));
1457
+        return new static( call_user_func_array( 'array_map', $params ) );
1458 1458
     }
1459 1459
 
1460 1460
     /**
@@ -1464,9 +1464,9 @@  discard block
 block discarded – undo
1464 1464
      */
1465 1465
     public function toArray()
1466 1466
     {
1467
-        return array_map(function ($value) {
1467
+        return array_map( function( $value ) {
1468 1468
             return $value instanceof Arrayable ? $value->toArray() : $value;
1469
-        }, $this->items);
1469
+        }, $this->items );
1470 1470
     }
1471 1471
 
1472 1472
     /**
@@ -1476,17 +1476,17 @@  discard block
 block discarded – undo
1476 1476
      */
1477 1477
     public function jsonSerialize()
1478 1478
     {
1479
-        return array_map(function ($value) {
1480
-            if ($value instanceof JsonSerializable) {
1479
+        return array_map( function( $value ) {
1480
+            if ( $value instanceof JsonSerializable ) {
1481 1481
                 return $value->jsonSerialize();
1482
-            } elseif ($value instanceof Jsonable) {
1483
-                return json_decode($value->toJson(), true);
1484
-            } elseif ($value instanceof Arrayable) {
1482
+            } elseif ( $value instanceof Jsonable ) {
1483
+                return json_decode( $value->toJson(), true );
1484
+            } elseif ( $value instanceof Arrayable ) {
1485 1485
                 return $value->toArray();
1486 1486
             } else {
1487 1487
                 return $value;
1488 1488
             }
1489
-        }, $this->items);
1489
+        }, $this->items );
1490 1490
     }
1491 1491
 
1492 1492
     /**
@@ -1495,9 +1495,9 @@  discard block
 block discarded – undo
1495 1495
      * @param  int  $options
1496 1496
      * @return string
1497 1497
      */
1498
-    public function toJson($options = 0)
1498
+    public function toJson( $options = 0 )
1499 1499
     {
1500
-        return json_encode($this->jsonSerialize(), $options);
1500
+        return json_encode( $this->jsonSerialize(), $options );
1501 1501
     }
1502 1502
 
1503 1503
     /**
@@ -1507,7 +1507,7 @@  discard block
 block discarded – undo
1507 1507
      */
1508 1508
     public function getIterator()
1509 1509
     {
1510
-        return new ArrayIterator($this->items);
1510
+        return new ArrayIterator( $this->items );
1511 1511
     }
1512 1512
 
1513 1513
     /**
@@ -1516,9 +1516,9 @@  discard block
 block discarded – undo
1516 1516
      * @param  int  $flags
1517 1517
      * @return \CachingIterator
1518 1518
      */
1519
-    public function getCachingIterator($flags = CachingIterator::CALL_TOSTRING)
1519
+    public function getCachingIterator( $flags = CachingIterator::CALL_TOSTRING )
1520 1520
     {
1521
-        return new CachingIterator($this->getIterator(), $flags);
1521
+        return new CachingIterator( $this->getIterator(), $flags );
1522 1522
     }
1523 1523
 
1524 1524
     /**
@@ -1528,7 +1528,7 @@  discard block
 block discarded – undo
1528 1528
      */
1529 1529
     public function count()
1530 1530
     {
1531
-        return count($this->items);
1531
+        return count( $this->items );
1532 1532
     }
1533 1533
 
1534 1534
     /**
@@ -1538,7 +1538,7 @@  discard block
 block discarded – undo
1538 1538
      */
1539 1539
     public function toBase()
1540 1540
     {
1541
-        return new self($this);
1541
+        return new self( $this );
1542 1542
     }
1543 1543
 
1544 1544
     /**
@@ -1547,9 +1547,9 @@  discard block
 block discarded – undo
1547 1547
      * @param  mixed  $key
1548 1548
      * @return bool
1549 1549
      */
1550
-    public function offsetExists($key)
1550
+    public function offsetExists( $key )
1551 1551
     {
1552
-        return array_key_exists($key, $this->items);
1552
+        return array_key_exists( $key, $this->items );
1553 1553
     }
1554 1554
 
1555 1555
     /**
@@ -1558,9 +1558,9 @@  discard block
 block discarded – undo
1558 1558
      * @param  mixed  $key
1559 1559
      * @return mixed
1560 1560
      */
1561
-    public function offsetGet($key)
1561
+    public function offsetGet( $key )
1562 1562
     {
1563
-        return $this->items[$key];
1563
+        return $this->items[ $key ];
1564 1564
     }
1565 1565
 
1566 1566
     /**
@@ -1570,12 +1570,12 @@  discard block
 block discarded – undo
1570 1570
      * @param  mixed  $value
1571 1571
      * @return void
1572 1572
      */
1573
-    public function offsetSet($key, $value)
1573
+    public function offsetSet( $key, $value )
1574 1574
     {
1575
-        if (is_null($key)) {
1576
-            $this->items[] = $value;
1575
+        if ( is_null( $key ) ) {
1576
+            $this->items[ ] = $value;
1577 1577
         } else {
1578
-            $this->items[$key] = $value;
1578
+            $this->items[ $key ] = $value;
1579 1579
         }
1580 1580
     }
1581 1581
 
@@ -1585,9 +1585,9 @@  discard block
 block discarded – undo
1585 1585
      * @param  string  $key
1586 1586
      * @return void
1587 1587
      */
1588
-    public function offsetUnset($key)
1588
+    public function offsetUnset( $key )
1589 1589
     {
1590
-        unset($this->items[$key]);
1590
+        unset( $this->items[ $key ] );
1591 1591
     }
1592 1592
 
1593 1593
     /**
@@ -1606,23 +1606,23 @@  discard block
 block discarded – undo
1606 1606
      * @param  mixed  $items
1607 1607
      * @return array
1608 1608
      */
1609
-    protected function getArrayableItems($items)
1609
+    protected function getArrayableItems( $items )
1610 1610
     {
1611
-        if (is_array($items)) {
1611
+        if ( is_array( $items ) ) {
1612 1612
             return $items;
1613
-        } elseif ($items instanceof self) {
1613
+        } elseif ( $items instanceof self ) {
1614 1614
             return $items->all();
1615
-        } elseif ($items instanceof Arrayable) {
1615
+        } elseif ( $items instanceof Arrayable ) {
1616 1616
             return $items->toArray();
1617
-        } elseif ($items instanceof Jsonable) {
1618
-            return json_decode($items->toJson(), true);
1619
-        } elseif ($items instanceof JsonSerializable) {
1617
+        } elseif ( $items instanceof Jsonable ) {
1618
+            return json_decode( $items->toJson(), true );
1619
+        } elseif ( $items instanceof JsonSerializable ) {
1620 1620
             return $items->jsonSerialize();
1621
-        } elseif ($items instanceof Traversable) {
1622
-            return iterator_to_array($items);
1621
+        } elseif ( $items instanceof Traversable ) {
1622
+            return iterator_to_array( $items );
1623 1623
         }
1624 1624
 
1625
-        return (array) $items;
1625
+        return (array)$items;
1626 1626
     }
1627 1627
 
1628 1628
     /**
@@ -1631,9 +1631,9 @@  discard block
 block discarded – undo
1631 1631
      * @param  string  $method
1632 1632
      * @return void
1633 1633
      */
1634
-    public static function proxy($method)
1634
+    public static function proxy( $method )
1635 1635
     {
1636
-        static::$proxies[] = $method;
1636
+        static::$proxies[ ] = $method;
1637 1637
     }
1638 1638
 
1639 1639
     /**
@@ -1644,12 +1644,12 @@  discard block
 block discarded – undo
1644 1644
      *
1645 1645
      * @throws \Exception
1646 1646
      */
1647
-    public function __get($key)
1647
+    public function __get( $key )
1648 1648
     {
1649
-        if (! in_array($key, static::$proxies)) {
1650
-            throw new Exception("Property [{$key}] does not exist on this collection instance.");
1649
+        if ( ! in_array( $key, static::$proxies ) ) {
1650
+            throw new Exception( "Property [{$key}] does not exist on this collection instance." );
1651 1651
         }
1652 1652
 
1653
-        return new HigherOrderCollectionProxy($this, $key);
1653
+        return new HigherOrderCollectionProxy( $this, $key );
1654 1654
     }
1655 1655
 }
Please login to merge, or discard this patch.
Braces   +105 added lines, -210 removed lines patch added patch discarded remove patch
@@ -41,8 +41,7 @@  discard block
 block discarded – undo
41 41
      * @param  mixed  $items
42 42
      * @return void
43 43
      */
44
-    public function __construct($items = [])
45
-    {
44
+    public function __construct($items = []) {
46 45
         $this->items = $this->getArrayableItems($items);
47 46
     }
48 47
 
@@ -52,8 +51,7 @@  discard block
 block discarded – undo
52 51
      * @param  mixed  $items
53 52
      * @return static
54 53
      */
55
-    public static function make($items = [])
56
-    {
54
+    public static function make($items = []) {
57 55
         return new static($items);
58 56
     }
59 57
 
@@ -64,8 +62,7 @@  discard block
 block discarded – undo
64 62
      * @param  callable  $callback
65 63
      * @return static
66 64
      */
67
-    public static function times($number, callable $callback = null)
68
-    {
65
+    public static function times($number, callable $callback = null) {
69 66
         if ($number < 1) {
70 67
             return new static;
71 68
         }
@@ -82,8 +79,7 @@  discard block
 block discarded – undo
82 79
      *
83 80
      * @return array
84 81
      */
85
-    public function all()
86
-    {
82
+    public function all() {
87 83
         return $this->items;
88 84
     }
89 85
 
@@ -93,8 +89,7 @@  discard block
 block discarded – undo
93 89
      * @param  callable|string|null  $callback
94 90
      * @return mixed
95 91
      */
96
-    public function avg($callback = null)
97
-    {
92
+    public function avg($callback = null) {
98 93
         if ($count = $this->count()) {
99 94
             return $this->sum($callback) / $count;
100 95
         }
@@ -106,8 +101,7 @@  discard block
 block discarded – undo
106 101
      * @param  callable|string|null  $callback
107 102
      * @return mixed
108 103
      */
109
-    public function average($callback = null)
110
-    {
104
+    public function average($callback = null) {
111 105
         return $this->avg($callback);
112 106
     }
113 107
 
@@ -117,8 +111,7 @@  discard block
 block discarded – undo
117 111
      * @param  null $key
118 112
      * @return mixed
119 113
      */
120
-    public function median($key = null)
121
-    {
114
+    public function median($key = null) {
122 115
         $count = $this->count();
123 116
 
124 117
         if ($count == 0) {
@@ -145,8 +138,7 @@  discard block
 block discarded – undo
145 138
      * @param  mixed  $key
146 139
      * @return array|null
147 140
      */
148
-    public function mode($key = null)
149
-    {
141
+    public function mode($key = null) {
150 142
         $count = $this->count();
151 143
 
152 144
         if ($count == 0) {
@@ -175,8 +167,7 @@  discard block
 block discarded – undo
175 167
      *
176 168
      * @return static
177 169
      */
178
-    public function collapse()
179
-    {
170
+    public function collapse() {
180 171
         return new static(Arr::collapse($this->items));
181 172
     }
182 173
 
@@ -188,8 +179,7 @@  discard block
 block discarded – undo
188 179
      * @param  mixed  $value
189 180
      * @return bool
190 181
      */
191
-    public function contains($key, $operator = null, $value = null)
192
-    {
182
+    public function contains($key, $operator = null, $value = null) {
193 183
         if (func_num_args() == 1) {
194 184
             if ($this->useAsCallable($key)) {
195 185
                 return ! is_null($this->first($key));
@@ -214,8 +204,7 @@  discard block
 block discarded – undo
214 204
      * @param  mixed  $value
215 205
      * @return bool
216 206
      */
217
-    public function containsStrict($key, $value = null)
218
-    {
207
+    public function containsStrict($key, $value = null) {
219 208
         if (func_num_args() == 2) {
220 209
             return $this->contains(function ($item) use ($key, $value) {
221 210
                 return data_get($item, $key) === $value;
@@ -235,8 +224,7 @@  discard block
 block discarded – undo
235 224
      * @param  mixed  ...$lists
236 225
      * @return static
237 226
      */
238
-    public function crossJoin(...$lists)
239
-    {
227
+    public function crossJoin(...$lists) {
240 228
         return new static(Arr::crossJoin(
241 229
             $this->items, ...array_map([$this, 'getArrayableItems'], $lists)
242 230
         ));
@@ -248,8 +236,7 @@  discard block
 block discarded – undo
248 236
      * @param  mixed  $items
249 237
      * @return static
250 238
      */
251
-    public function diff($items)
252
-    {
239
+    public function diff($items) {
253 240
         return new static(array_diff($this->items, $this->getArrayableItems($items)));
254 241
     }
255 242
 
@@ -259,8 +246,7 @@  discard block
 block discarded – undo
259 246
      * @param  mixed  $items
260 247
      * @return static
261 248
      */
262
-    public function diffAssoc($items)
263
-    {
249
+    public function diffAssoc($items) {
264 250
         return new static(array_diff_assoc($this->items, $this->getArrayableItems($items)));
265 251
     }
266 252
 
@@ -270,8 +256,7 @@  discard block
 block discarded – undo
270 256
      * @param  mixed  $items
271 257
      * @return static
272 258
      */
273
-    public function diffKeys($items)
274
-    {
259
+    public function diffKeys($items) {
275 260
         return new static(array_diff_key($this->items, $this->getArrayableItems($items)));
276 261
     }
277 262
 
@@ -281,8 +266,7 @@  discard block
 block discarded – undo
281 266
      * @param  callable  $callback
282 267
      * @return $this
283 268
      */
284
-    public function each(callable $callback)
285
-    {
269
+    public function each(callable $callback) {
286 270
         foreach ($this->items as $key => $item) {
287 271
             if ($callback($item, $key) === false) {
288 272
                 break;
@@ -298,8 +282,7 @@  discard block
 block discarded – undo
298 282
      * @param  callable  $callback
299 283
      * @return static
300 284
      */
301
-    public function eachSpread(callable $callback)
302
-    {
285
+    public function eachSpread(callable $callback) {
303 286
         return $this->each(function ($chunk) use ($callback) {
304 287
             return $callback(...$chunk);
305 288
         });
@@ -313,8 +296,7 @@  discard block
 block discarded – undo
313 296
      * @param  mixed  $value
314 297
      * @return bool
315 298
      */
316
-    public function every($key, $operator = null, $value = null)
317
-    {
299
+    public function every($key, $operator = null, $value = null) {
318 300
         if (func_num_args() == 1) {
319 301
             $callback = $this->valueRetriever($key);
320 302
 
@@ -342,8 +324,7 @@  discard block
 block discarded – undo
342 324
      * @param  mixed  $keys
343 325
      * @return static
344 326
      */
345
-    public function except($keys)
346
-    {
327
+    public function except($keys) {
347 328
         $keys = is_array($keys) ? $keys : func_get_args();
348 329
 
349 330
         return new static(Arr::except($this->items, $keys));
@@ -355,8 +336,7 @@  discard block
 block discarded – undo
355 336
      * @param  callable|null  $callback
356 337
      * @return static
357 338
      */
358
-    public function filter(callable $callback = null)
359
-    {
339
+    public function filter(callable $callback = null) {
360 340
         if ($callback) {
361 341
             return new static(Arr::where($this->items, $callback));
362 342
         }
@@ -372,8 +352,7 @@  discard block
 block discarded – undo
372 352
      * @param  callable  $default
373 353
      * @return mixed
374 354
      */
375
-    public function when($value, callable $callback, callable $default = null)
376
-    {
355
+    public function when($value, callable $callback, callable $default = null) {
377 356
         if ($value) {
378 357
             return $callback($this);
379 358
         } elseif ($default) {
@@ -391,8 +370,7 @@  discard block
 block discarded – undo
391 370
      * @param  callable  $default
392 371
      * @return mixed
393 372
      */
394
-    public function unless($value, callable $callback, callable $default = null)
395
-    {
373
+    public function unless($value, callable $callback, callable $default = null) {
396 374
         return $this->when(! $value, $callback, $default);
397 375
     }
398 376
 
@@ -404,8 +382,7 @@  discard block
 block discarded – undo
404 382
      * @param  mixed  $value
405 383
      * @return static
406 384
      */
407
-    public function where($key, $operator, $value = null)
408
-    {
385
+    public function where($key, $operator, $value = null) {
409 386
         if (func_num_args() == 2) {
410 387
             $value = $operator;
411 388
 
@@ -423,8 +400,7 @@  discard block
 block discarded – undo
423 400
      * @param  mixed  $value
424 401
      * @return \Closure
425 402
      */
426
-    protected function operatorForWhere($key, $operator, $value)
427
-    {
403
+    protected function operatorForWhere($key, $operator, $value) {
428 404
         return function ($item) use ($key, $operator, $value) {
429 405
             $retrieved = data_get($item, $key);
430 406
 
@@ -451,8 +427,7 @@  discard block
 block discarded – undo
451 427
      * @param  mixed  $value
452 428
      * @return static
453 429
      */
454
-    public function whereStrict($key, $value)
455
-    {
430
+    public function whereStrict($key, $value) {
456 431
         return $this->where($key, '===', $value);
457 432
     }
458 433
 
@@ -464,8 +439,7 @@  discard block
 block discarded – undo
464 439
      * @param  bool  $strict
465 440
      * @return static
466 441
      */
467
-    public function whereIn($key, $values, $strict = false)
468
-    {
442
+    public function whereIn($key, $values, $strict = false) {
469 443
         $values = $this->getArrayableItems($values);
470 444
 
471 445
         return $this->filter(function ($item) use ($key, $values, $strict) {
@@ -480,8 +454,7 @@  discard block
 block discarded – undo
480 454
      * @param  mixed  $values
481 455
      * @return static
482 456
      */
483
-    public function whereInStrict($key, $values)
484
-    {
457
+    public function whereInStrict($key, $values) {
485 458
         return $this->whereIn($key, $values, true);
486 459
     }
487 460
 
@@ -493,8 +466,7 @@  discard block
 block discarded – undo
493 466
      * @param  bool  $strict
494 467
      * @return static
495 468
      */
496
-    public function whereNotIn($key, $values, $strict = false)
497
-    {
469
+    public function whereNotIn($key, $values, $strict = false) {
498 470
         $values = $this->getArrayableItems($values);
499 471
 
500 472
         return $this->reject(function ($item) use ($key, $values, $strict) {
@@ -509,8 +481,7 @@  discard block
 block discarded – undo
509 481
      * @param  mixed  $values
510 482
      * @return static
511 483
      */
512
-    public function whereNotInStrict($key, $values)
513
-    {
484
+    public function whereNotInStrict($key, $values) {
514 485
         return $this->whereNotIn($key, $values, true);
515 486
     }
516 487
 
@@ -521,8 +492,7 @@  discard block
 block discarded – undo
521 492
      * @param  mixed  $default
522 493
      * @return mixed
523 494
      */
524
-    public function first(callable $callback = null, $default = null)
525
-    {
495
+    public function first(callable $callback = null, $default = null) {
526 496
         return Arr::first($this->items, $callback, $default);
527 497
     }
528 498
 
@@ -532,8 +502,7 @@  discard block
 block discarded – undo
532 502
      * @param  int  $depth
533 503
      * @return static
534 504
      */
535
-    public function flatten($depth = INF)
536
-    {
505
+    public function flatten($depth = INF) {
537 506
         return new static(Arr::flatten($this->items, $depth));
538 507
     }
539 508
 
@@ -542,8 +511,7 @@  discard block
 block discarded – undo
542 511
      *
543 512
      * @return static
544 513
      */
545
-    public function flip()
546
-    {
514
+    public function flip() {
547 515
         return new static(array_flip($this->items));
548 516
     }
549 517
 
@@ -553,8 +521,7 @@  discard block
 block discarded – undo
553 521
      * @param  string|array  $keys
554 522
      * @return $this
555 523
      */
556
-    public function forget($keys)
557
-    {
524
+    public function forget($keys) {
558 525
         foreach ((array) $keys as $key) {
559 526
             $this->offsetUnset($key);
560 527
         }
@@ -569,8 +536,7 @@  discard block
 block discarded – undo
569 536
      * @param  mixed  $default
570 537
      * @return mixed
571 538
      */
572
-    public function get($key, $default = null)
573
-    {
539
+    public function get($key, $default = null) {
574 540
         if ($this->offsetExists($key)) {
575 541
             return $this->items[$key];
576 542
         }
@@ -585,8 +551,7 @@  discard block
 block discarded – undo
585 551
      * @param  bool  $preserveKeys
586 552
      * @return static
587 553
      */
588
-    public function groupBy($groupBy, $preserveKeys = false)
589
-    {
554
+    public function groupBy($groupBy, $preserveKeys = false) {
590 555
         $groupBy = $this->valueRetriever($groupBy);
591 556
 
592 557
         $results = [];
@@ -618,8 +583,7 @@  discard block
 block discarded – undo
618 583
      * @param  callable|string  $keyBy
619 584
      * @return static
620 585
      */
621
-    public function keyBy($keyBy)
622
-    {
586
+    public function keyBy($keyBy) {
623 587
         $keyBy = $this->valueRetriever($keyBy);
624 588
 
625 589
         $results = [];
@@ -643,8 +607,7 @@  discard block
 block discarded – undo
643 607
      * @param  mixed  $key
644 608
      * @return bool
645 609
      */
646
-    public function has($key)
647
-    {
610
+    public function has($key) {
648 611
         return $this->offsetExists($key);
649 612
     }
650 613
 
@@ -655,8 +618,7 @@  discard block
 block discarded – undo
655 618
      * @param  string  $glue
656 619
      * @return string
657 620
      */
658
-    public function implode($value, $glue = null)
659
-    {
621
+    public function implode($value, $glue = null) {
660 622
         $first = $this->first();
661 623
 
662 624
         if (is_array($first) || is_object($first)) {
@@ -672,8 +634,7 @@  discard block
 block discarded – undo
672 634
      * @param  mixed  $items
673 635
      * @return static
674 636
      */
675
-    public function intersect($items)
676
-    {
637
+    public function intersect($items) {
677 638
         return new static(array_intersect($this->items, $this->getArrayableItems($items)));
678 639
     }
679 640
 
@@ -683,8 +644,7 @@  discard block
 block discarded – undo
683 644
      * @param  mixed  $items
684 645
      * @return static
685 646
      */
686
-    public function intersectKey($items)
687
-    {
647
+    public function intersectKey($items) {
688 648
         return new static(array_intersect_key($this->items, $this->getArrayableItems($items)));
689 649
     }
690 650
 
@@ -693,8 +653,7 @@  discard block
 block discarded – undo
693 653
      *
694 654
      * @return bool
695 655
      */
696
-    public function isEmpty()
697
-    {
656
+    public function isEmpty() {
698 657
         return empty($this->items);
699 658
     }
700 659
 
@@ -703,8 +662,7 @@  discard block
 block discarded – undo
703 662
      *
704 663
      * @return bool
705 664
      */
706
-    public function isNotEmpty()
707
-    {
665
+    public function isNotEmpty() {
708 666
         return ! $this->isEmpty();
709 667
     }
710 668
 
@@ -714,8 +672,7 @@  discard block
 block discarded – undo
714 672
      * @param  mixed  $value
715 673
      * @return bool
716 674
      */
717
-    protected function useAsCallable($value)
718
-    {
675
+    protected function useAsCallable($value) {
719 676
         return ! is_string($value) && is_callable($value);
720 677
     }
721 678
 
@@ -724,8 +681,7 @@  discard block
 block discarded – undo
724 681
      *
725 682
      * @return static
726 683
      */
727
-    public function keys()
728
-    {
684
+    public function keys() {
729 685
         return new static(array_keys($this->items));
730 686
     }
731 687
 
@@ -736,8 +692,7 @@  discard block
 block discarded – undo
736 692
      * @param  mixed  $default
737 693
      * @return mixed
738 694
      */
739
-    public function last(callable $callback = null, $default = null)
740
-    {
695
+    public function last(callable $callback = null, $default = null) {
741 696
         return Arr::last($this->items, $callback, $default);
742 697
     }
743 698
 
@@ -748,8 +703,7 @@  discard block
 block discarded – undo
748 703
      * @param  string|null  $key
749 704
      * @return static
750 705
      */
751
-    public function pluck($value, $key = null)
752
-    {
706
+    public function pluck($value, $key = null) {
753 707
         return new static(Arr::pluck($this->items, $value, $key));
754 708
     }
755 709
 
@@ -759,8 +713,7 @@  discard block
 block discarded – undo
759 713
      * @param  callable  $callback
760 714
      * @return static
761 715
      */
762
-    public function map(callable $callback)
763
-    {
716
+    public function map(callable $callback) {
764 717
         $keys = array_keys($this->items);
765 718
 
766 719
         $items = array_map($callback, $this->items, $keys);
@@ -774,8 +727,7 @@  discard block
 block discarded – undo
774 727
      * @param  callable  $callback
775 728
      * @return static
776 729
      */
777
-    public function mapSpread(callable $callback)
778
-    {
730
+    public function mapSpread(callable $callback) {
779 731
         return $this->map(function ($chunk) use ($callback) {
780 732
             return $callback(...$chunk);
781 733
         });
@@ -789,8 +741,7 @@  discard block
 block discarded – undo
789 741
      * @param  callable  $callback
790 742
      * @return static
791 743
      */
792
-    public function mapToGroups(callable $callback)
793
-    {
744
+    public function mapToGroups(callable $callback) {
794 745
         $groups = $this->map($callback)->reduce(function ($groups, $pair) {
795 746
             $groups[key($pair)][] = reset($pair);
796 747
 
@@ -808,8 +759,7 @@  discard block
 block discarded – undo
808 759
      * @param  callable  $callback
809 760
      * @return static
810 761
      */
811
-    public function mapWithKeys(callable $callback)
812
-    {
762
+    public function mapWithKeys(callable $callback) {
813 763
         $result = [];
814 764
 
815 765
         foreach ($this->items as $key => $value) {
@@ -829,8 +779,7 @@  discard block
 block discarded – undo
829 779
      * @param  callable  $callback
830 780
      * @return static
831 781
      */
832
-    public function flatMap(callable $callback)
833
-    {
782
+    public function flatMap(callable $callback) {
834 783
         return $this->map($callback)->collapse();
835 784
     }
836 785
 
@@ -840,8 +789,7 @@  discard block
 block discarded – undo
840 789
      * @param  callable|string|null  $callback
841 790
      * @return mixed
842 791
      */
843
-    public function max($callback = null)
844
-    {
792
+    public function max($callback = null) {
845 793
         $callback = $this->valueRetriever($callback);
846 794
 
847 795
         return $this->filter(function ($value) {
@@ -859,8 +807,7 @@  discard block
 block discarded – undo
859 807
      * @param  mixed  $items
860 808
      * @return static
861 809
      */
862
-    public function merge($items)
863
-    {
810
+    public function merge($items) {
864 811
         return new static(array_merge($this->items, $this->getArrayableItems($items)));
865 812
     }
866 813
 
@@ -870,8 +817,7 @@  discard block
 block discarded – undo
870 817
      * @param  mixed  $values
871 818
      * @return static
872 819
      */
873
-    public function combine($values)
874
-    {
820
+    public function combine($values) {
875 821
         return new static(array_combine($this->all(), $this->getArrayableItems($values)));
876 822
     }
877 823
 
@@ -881,8 +827,7 @@  discard block
 block discarded – undo
881 827
      * @param  mixed  $items
882 828
      * @return static
883 829
      */
884
-    public function union($items)
885
-    {
830
+    public function union($items) {
886 831
         return new static($this->items + $this->getArrayableItems($items));
887 832
     }
888 833
 
@@ -892,8 +837,7 @@  discard block
 block discarded – undo
892 837
      * @param  callable|string|null  $callback
893 838
      * @return mixed
894 839
      */
895
-    public function min($callback = null)
896
-    {
840
+    public function min($callback = null) {
897 841
         $callback = $this->valueRetriever($callback);
898 842
 
899 843
         return $this->filter(function ($value) {
@@ -912,8 +856,7 @@  discard block
 block discarded – undo
912 856
      * @param  int  $offset
913 857
      * @return static
914 858
      */
915
-    public function nth($step, $offset = 0)
916
-    {
859
+    public function nth($step, $offset = 0) {
917 860
         $new = [];
918 861
 
919 862
         $position = 0;
@@ -935,8 +878,7 @@  discard block
 block discarded – undo
935 878
      * @param  mixed  $keys
936 879
      * @return static
937 880
      */
938
-    public function only($keys)
939
-    {
881
+    public function only($keys) {
940 882
         if (is_null($keys)) {
941 883
             return new static($this->items);
942 884
         }
@@ -953,8 +895,7 @@  discard block
 block discarded – undo
953 895
      * @param  int  $perPage
954 896
      * @return static
955 897
      */
956
-    public function forPage($page, $perPage)
957
-    {
898
+    public function forPage($page, $perPage) {
958 899
         return $this->slice(($page - 1) * $perPage, $perPage);
959 900
     }
960 901
 
@@ -964,8 +905,7 @@  discard block
 block discarded – undo
964 905
      * @param  callable|string  $callback
965 906
      * @return static
966 907
      */
967
-    public function partition($callback)
968
-    {
908
+    public function partition($callback) {
969 909
         $partitions = [new static, new static];
970 910
 
971 911
         $callback = $this->valueRetriever($callback);
@@ -983,8 +923,7 @@  discard block
 block discarded – undo
983 923
      * @param  callable $callback
984 924
      * @return mixed
985 925
      */
986
-    public function pipe(callable $callback)
987
-    {
926
+    public function pipe(callable $callback) {
988 927
         return $callback($this);
989 928
     }
990 929
 
@@ -993,8 +932,7 @@  discard block
 block discarded – undo
993 932
      *
994 933
      * @return mixed
995 934
      */
996
-    public function pop()
997
-    {
935
+    public function pop() {
998 936
         return array_pop($this->items);
999 937
     }
1000 938
 
@@ -1005,8 +943,7 @@  discard block
 block discarded – undo
1005 943
      * @param  mixed  $key
1006 944
      * @return $this
1007 945
      */
1008
-    public function prepend($value, $key = null)
1009
-    {
946
+    public function prepend($value, $key = null) {
1010 947
         $this->items = Arr::prepend($this->items, $value, $key);
1011 948
 
1012 949
         return $this;
@@ -1018,8 +955,7 @@  discard block
 block discarded – undo
1018 955
      * @param  mixed  $value
1019 956
      * @return $this
1020 957
      */
1021
-    public function push($value)
1022
-    {
958
+    public function push($value) {
1023 959
         $this->offsetSet(null, $value);
1024 960
 
1025 961
         return $this;
@@ -1031,8 +967,7 @@  discard block
 block discarded – undo
1031 967
      * @param  \Traversable  $source
1032 968
      * @return self
1033 969
      */
1034
-    public function concat($source)
1035
-    {
970
+    public function concat($source) {
1036 971
         $result = new static($this);
1037 972
 
1038 973
         foreach ($source as $item) {
@@ -1049,8 +984,7 @@  discard block
 block discarded – undo
1049 984
      * @param  mixed  $default
1050 985
      * @return mixed
1051 986
      */
1052
-    public function pull($key, $default = null)
1053
-    {
987
+    public function pull($key, $default = null) {
1054 988
         return Arr::pull($this->items, $key, $default);
1055 989
     }
1056 990
 
@@ -1061,8 +995,7 @@  discard block
 block discarded – undo
1061 995
      * @param  mixed  $value
1062 996
      * @return $this
1063 997
      */
1064
-    public function put($key, $value)
1065
-    {
998
+    public function put($key, $value) {
1066 999
         $this->offsetSet($key, $value);
1067 1000
 
1068 1001
         return $this;
@@ -1076,8 +1009,7 @@  discard block
 block discarded – undo
1076 1009
      *
1077 1010
      * @throws \InvalidArgumentException
1078 1011
      */
1079
-    public function random($number = null)
1080
-    {
1012
+    public function random($number = null) {
1081 1013
         if (is_null($number)) {
1082 1014
             return Arr::random($this->items);
1083 1015
         }
@@ -1092,8 +1024,7 @@  discard block
 block discarded – undo
1092 1024
      * @param  mixed  $initial
1093 1025
      * @return mixed
1094 1026
      */
1095
-    public function reduce(callable $callback, $initial = null)
1096
-    {
1027
+    public function reduce(callable $callback, $initial = null) {
1097 1028
         return array_reduce($this->items, $callback, $initial);
1098 1029
     }
1099 1030
 
@@ -1103,8 +1034,7 @@  discard block
 block discarded – undo
1103 1034
      * @param  callable|mixed  $callback
1104 1035
      * @return static
1105 1036
      */
1106
-    public function reject($callback)
1107
-    {
1037
+    public function reject($callback) {
1108 1038
         if ($this->useAsCallable($callback)) {
1109 1039
             return $this->filter(function ($value, $key) use ($callback) {
1110 1040
                 return ! $callback($value, $key);
@@ -1121,8 +1051,7 @@  discard block
 block discarded – undo
1121 1051
      *
1122 1052
      * @return static
1123 1053
      */
1124
-    public function reverse()
1125
-    {
1054
+    public function reverse() {
1126 1055
         return new static(array_reverse($this->items, true));
1127 1056
     }
1128 1057
 
@@ -1133,8 +1062,7 @@  discard block
 block discarded – undo
1133 1062
      * @param  bool  $strict
1134 1063
      * @return mixed
1135 1064
      */
1136
-    public function search($value, $strict = false)
1137
-    {
1065
+    public function search($value, $strict = false) {
1138 1066
         if (! $this->useAsCallable($value)) {
1139 1067
             return array_search($value, $this->items, $strict);
1140 1068
         }
@@ -1153,8 +1081,7 @@  discard block
 block discarded – undo
1153 1081
      *
1154 1082
      * @return mixed
1155 1083
      */
1156
-    public function shift()
1157
-    {
1084
+    public function shift() {
1158 1085
         return array_shift($this->items);
1159 1086
     }
1160 1087
 
@@ -1164,8 +1091,7 @@  discard block
 block discarded – undo
1164 1091
      * @param  int  $seed
1165 1092
      * @return static
1166 1093
      */
1167
-    public function shuffle($seed = null)
1168
-    {
1094
+    public function shuffle($seed = null) {
1169 1095
         $items = $this->items;
1170 1096
 
1171 1097
         if (is_null($seed)) {
@@ -1188,8 +1114,7 @@  discard block
 block discarded – undo
1188 1114
      * @param  int  $length
1189 1115
      * @return static
1190 1116
      */
1191
-    public function slice($offset, $length = null)
1192
-    {
1117
+    public function slice($offset, $length = null) {
1193 1118
         return new static(array_slice($this->items, $offset, $length, true));
1194 1119
     }
1195 1120
 
@@ -1199,8 +1124,7 @@  discard block
 block discarded – undo
1199 1124
      * @param  int  $numberOfGroups
1200 1125
      * @return static
1201 1126
      */
1202
-    public function split($numberOfGroups)
1203
-    {
1127
+    public function split($numberOfGroups) {
1204 1128
         if ($this->isEmpty()) {
1205 1129
             return new static;
1206 1130
         }
@@ -1216,8 +1140,7 @@  discard block
 block discarded – undo
1216 1140
      * @param  int  $size
1217 1141
      * @return static
1218 1142
      */
1219
-    public function chunk($size)
1220
-    {
1143
+    public function chunk($size) {
1221 1144
         if ($size <= 0) {
1222 1145
             return new static;
1223 1146
         }
@@ -1237,8 +1160,7 @@  discard block
 block discarded – undo
1237 1160
      * @param  callable|null  $callback
1238 1161
      * @return static
1239 1162
      */
1240
-    public function sort(callable $callback = null)
1241
-    {
1163
+    public function sort(callable $callback = null) {
1242 1164
         $items = $this->items;
1243 1165
 
1244 1166
         $callback
@@ -1256,8 +1178,7 @@  discard block
 block discarded – undo
1256 1178
      * @param  bool  $descending
1257 1179
      * @return static
1258 1180
      */
1259
-    public function sortBy($callback, $options = SORT_REGULAR, $descending = false)
1260
-    {
1181
+    public function sortBy($callback, $options = SORT_REGULAR, $descending = false) {
1261 1182
         $results = [];
1262 1183
 
1263 1184
         $callback = $this->valueRetriever($callback);
@@ -1289,8 +1210,7 @@  discard block
 block discarded – undo
1289 1210
      * @param  int  $options
1290 1211
      * @return static
1291 1212
      */
1292
-    public function sortByDesc($callback, $options = SORT_REGULAR)
1293
-    {
1213
+    public function sortByDesc($callback, $options = SORT_REGULAR) {
1294 1214
         return $this->sortBy($callback, $options, true);
1295 1215
     }
1296 1216
 
@@ -1302,8 +1222,7 @@  discard block
 block discarded – undo
1302 1222
      * @param  mixed  $replacement
1303 1223
      * @return static
1304 1224
      */
1305
-    public function splice($offset, $length = null, $replacement = [])
1306
-    {
1225
+    public function splice($offset, $length = null, $replacement = []) {
1307 1226
         if (func_num_args() == 1) {
1308 1227
             return new static(array_splice($this->items, $offset));
1309 1228
         }
@@ -1317,8 +1236,7 @@  discard block
 block discarded – undo
1317 1236
      * @param  callable|string|null  $callback
1318 1237
      * @return mixed
1319 1238
      */
1320
-    public function sum($callback = null)
1321
-    {
1239
+    public function sum($callback = null) {
1322 1240
         if (is_null($callback)) {
1323 1241
             return array_sum($this->items);
1324 1242
         }
@@ -1336,8 +1254,7 @@  discard block
 block discarded – undo
1336 1254
      * @param  int  $limit
1337 1255
      * @return static
1338 1256
      */
1339
-    public function take($limit)
1340
-    {
1257
+    public function take($limit) {
1341 1258
         if ($limit < 0) {
1342 1259
             return $this->slice($limit, abs($limit));
1343 1260
         }
@@ -1351,8 +1268,7 @@  discard block
 block discarded – undo
1351 1268
      * @param  callable  $callback
1352 1269
      * @return $this
1353 1270
      */
1354
-    public function tap(callable $callback)
1355
-    {
1271
+    public function tap(callable $callback) {
1356 1272
         $callback(new static($this->items));
1357 1273
 
1358 1274
         return $this;
@@ -1364,8 +1280,7 @@  discard block
 block discarded – undo
1364 1280
      * @param  callable  $callback
1365 1281
      * @return $this
1366 1282
      */
1367
-    public function transform(callable $callback)
1368
-    {
1283
+    public function transform(callable $callback) {
1369 1284
         $this->items = $this->map($callback)->all();
1370 1285
 
1371 1286
         return $this;
@@ -1378,8 +1293,7 @@  discard block
 block discarded – undo
1378 1293
      * @param  bool  $strict
1379 1294
      * @return static
1380 1295
      */
1381
-    public function unique($key = null, $strict = false)
1382
-    {
1296
+    public function unique($key = null, $strict = false) {
1383 1297
         if (is_null($key)) {
1384 1298
             return new static(array_unique($this->items, SORT_REGULAR));
1385 1299
         }
@@ -1403,8 +1317,7 @@  discard block
 block discarded – undo
1403 1317
      * @param  string|callable|null  $key
1404 1318
      * @return static
1405 1319
      */
1406
-    public function uniqueStrict($key = null)
1407
-    {
1320
+    public function uniqueStrict($key = null) {
1408 1321
         return $this->unique($key, true);
1409 1322
     }
1410 1323
 
@@ -1413,8 +1326,7 @@  discard block
 block discarded – undo
1413 1326
      *
1414 1327
      * @return static
1415 1328
      */
1416
-    public function values()
1417
-    {
1329
+    public function values() {
1418 1330
         return new static(array_values($this->items));
1419 1331
     }
1420 1332
 
@@ -1424,8 +1336,7 @@  discard block
 block discarded – undo
1424 1336
      * @param  string  $value
1425 1337
      * @return callable
1426 1338
      */
1427
-    protected function valueRetriever($value)
1428
-    {
1339
+    protected function valueRetriever($value) {
1429 1340
         if ($this->useAsCallable($value)) {
1430 1341
             return $value;
1431 1342
         }
@@ -1444,8 +1355,7 @@  discard block
 block discarded – undo
1444 1355
      * @param  mixed ...$items
1445 1356
      * @return static
1446 1357
      */
1447
-    public function zip($items)
1448
-    {
1358
+    public function zip($items) {
1449 1359
         $arrayableItems = array_map(function ($items) {
1450 1360
             return $this->getArrayableItems($items);
1451 1361
         }, func_get_args());
@@ -1462,8 +1372,7 @@  discard block
 block discarded – undo
1462 1372
      *
1463 1373
      * @return array
1464 1374
      */
1465
-    public function toArray()
1466
-    {
1375
+    public function toArray() {
1467 1376
         return array_map(function ($value) {
1468 1377
             return $value instanceof Arrayable ? $value->toArray() : $value;
1469 1378
         }, $this->items);
@@ -1474,8 +1383,7 @@  discard block
 block discarded – undo
1474 1383
      *
1475 1384
      * @return array
1476 1385
      */
1477
-    public function jsonSerialize()
1478
-    {
1386
+    public function jsonSerialize() {
1479 1387
         return array_map(function ($value) {
1480 1388
             if ($value instanceof JsonSerializable) {
1481 1389
                 return $value->jsonSerialize();
@@ -1495,8 +1403,7 @@  discard block
 block discarded – undo
1495 1403
      * @param  int  $options
1496 1404
      * @return string
1497 1405
      */
1498
-    public function toJson($options = 0)
1499
-    {
1406
+    public function toJson($options = 0) {
1500 1407
         return json_encode($this->jsonSerialize(), $options);
1501 1408
     }
1502 1409
 
@@ -1505,8 +1412,7 @@  discard block
 block discarded – undo
1505 1412
      *
1506 1413
      * @return \ArrayIterator
1507 1414
      */
1508
-    public function getIterator()
1509
-    {
1415
+    public function getIterator() {
1510 1416
         return new ArrayIterator($this->items);
1511 1417
     }
1512 1418
 
@@ -1516,8 +1422,7 @@  discard block
 block discarded – undo
1516 1422
      * @param  int  $flags
1517 1423
      * @return \CachingIterator
1518 1424
      */
1519
-    public function getCachingIterator($flags = CachingIterator::CALL_TOSTRING)
1520
-    {
1425
+    public function getCachingIterator($flags = CachingIterator::CALL_TOSTRING) {
1521 1426
         return new CachingIterator($this->getIterator(), $flags);
1522 1427
     }
1523 1428
 
@@ -1526,8 +1431,7 @@  discard block
 block discarded – undo
1526 1431
      *
1527 1432
      * @return int
1528 1433
      */
1529
-    public function count()
1530
-    {
1434
+    public function count() {
1531 1435
         return count($this->items);
1532 1436
     }
1533 1437
 
@@ -1536,8 +1440,7 @@  discard block
 block discarded – undo
1536 1440
      *
1537 1441
      * @return \Illuminate\Support\Collection
1538 1442
      */
1539
-    public function toBase()
1540
-    {
1443
+    public function toBase() {
1541 1444
         return new self($this);
1542 1445
     }
1543 1446
 
@@ -1547,8 +1450,7 @@  discard block
 block discarded – undo
1547 1450
      * @param  mixed  $key
1548 1451
      * @return bool
1549 1452
      */
1550
-    public function offsetExists($key)
1551
-    {
1453
+    public function offsetExists($key) {
1552 1454
         return array_key_exists($key, $this->items);
1553 1455
     }
1554 1456
 
@@ -1558,8 +1460,7 @@  discard block
 block discarded – undo
1558 1460
      * @param  mixed  $key
1559 1461
      * @return mixed
1560 1462
      */
1561
-    public function offsetGet($key)
1562
-    {
1463
+    public function offsetGet($key) {
1563 1464
         return $this->items[$key];
1564 1465
     }
1565 1466
 
@@ -1570,8 +1471,7 @@  discard block
 block discarded – undo
1570 1471
      * @param  mixed  $value
1571 1472
      * @return void
1572 1473
      */
1573
-    public function offsetSet($key, $value)
1574
-    {
1474
+    public function offsetSet($key, $value) {
1575 1475
         if (is_null($key)) {
1576 1476
             $this->items[] = $value;
1577 1477
         } else {
@@ -1585,8 +1485,7 @@  discard block
 block discarded – undo
1585 1485
      * @param  string  $key
1586 1486
      * @return void
1587 1487
      */
1588
-    public function offsetUnset($key)
1589
-    {
1488
+    public function offsetUnset($key) {
1590 1489
         unset($this->items[$key]);
1591 1490
     }
1592 1491
 
@@ -1595,8 +1494,7 @@  discard block
 block discarded – undo
1595 1494
      *
1596 1495
      * @return string
1597 1496
      */
1598
-    public function __toString()
1599
-    {
1497
+    public function __toString() {
1600 1498
         return $this->toJson();
1601 1499
     }
1602 1500
 
@@ -1606,8 +1504,7 @@  discard block
 block discarded – undo
1606 1504
      * @param  mixed  $items
1607 1505
      * @return array
1608 1506
      */
1609
-    protected function getArrayableItems($items)
1610
-    {
1507
+    protected function getArrayableItems($items) {
1611 1508
         if (is_array($items)) {
1612 1509
             return $items;
1613 1510
         } elseif ($items instanceof self) {
@@ -1631,8 +1528,7 @@  discard block
 block discarded – undo
1631 1528
      * @param  string  $method
1632 1529
      * @return void
1633 1530
      */
1634
-    public static function proxy($method)
1635
-    {
1531
+    public static function proxy($method) {
1636 1532
         static::$proxies[] = $method;
1637 1533
     }
1638 1534
 
@@ -1644,8 +1540,7 @@  discard block
 block discarded – undo
1644 1540
      *
1645 1541
      * @throws \Exception
1646 1542
      */
1647
-    public function __get($key)
1648
-    {
1543
+    public function __get($key) {
1649 1544
         if (! in_array($key, static::$proxies)) {
1650 1545
             throw new Exception("Property [{$key}] does not exist on this collection instance.");
1651 1546
         }
Please login to merge, or discard this patch.
vendor/illuminate/support/Facades/Input.php 3 patches
Indentation   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -7,27 +7,27 @@
 block discarded – undo
7 7
  */
8 8
 class Input extends Facade
9 9
 {
10
-    /**
11
-     * Get an item from the input data.
12
-     *
13
-     * This method is used for all request verbs (GET, POST, PUT, and DELETE)
14
-     *
15
-     * @param  string  $key
16
-     * @param  mixed   $default
17
-     * @return mixed
18
-     */
19
-    public static function get($key = null, $default = null)
20
-    {
21
-        return static::$app['request']->input($key, $default);
22
-    }
10
+	/**
11
+	 * Get an item from the input data.
12
+	 *
13
+	 * This method is used for all request verbs (GET, POST, PUT, and DELETE)
14
+	 *
15
+	 * @param  string  $key
16
+	 * @param  mixed   $default
17
+	 * @return mixed
18
+	 */
19
+	public static function get($key = null, $default = null)
20
+	{
21
+		return static::$app['request']->input($key, $default);
22
+	}
23 23
 
24
-    /**
25
-     * Get the registered name of the component.
26
-     *
27
-     * @return string
28
-     */
29
-    protected static function getFacadeAccessor()
30
-    {
31
-        return 'request';
32
-    }
24
+	/**
25
+	 * Get the registered name of the component.
26
+	 *
27
+	 * @return string
28
+	 */
29
+	protected static function getFacadeAccessor()
30
+	{
31
+		return 'request';
32
+	}
33 33
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -16,9 +16,9 @@
 block discarded – undo
16 16
      * @param  mixed   $default
17 17
      * @return mixed
18 18
      */
19
-    public static function get($key = null, $default = null)
19
+    public static function get( $key = null, $default = null )
20 20
     {
21
-        return static::$app['request']->input($key, $default);
21
+        return static::$app[ 'request' ]->input( $key, $default );
22 22
     }
23 23
 
24 24
     /**
Please login to merge, or discard this patch.
Braces   +3 added lines, -6 removed lines patch added patch discarded remove patch
@@ -5,8 +5,7 @@  discard block
 block discarded – undo
5 5
 /**
6 6
  * @see \Illuminate\Http\Request
7 7
  */
8
-class Input extends Facade
9
-{
8
+class Input extends Facade {
10 9
     /**
11 10
      * Get an item from the input data.
12 11
      *
@@ -16,8 +15,7 @@  discard block
 block discarded – undo
16 15
      * @param  mixed   $default
17 16
      * @return mixed
18 17
      */
19
-    public static function get($key = null, $default = null)
20
-    {
18
+    public static function get($key = null, $default = null) {
21 19
         return static::$app['request']->input($key, $default);
22 20
     }
23 21
 
@@ -26,8 +24,7 @@  discard block
 block discarded – undo
26 24
      *
27 25
      * @return string
28 26
      */
29
-    protected static function getFacadeAccessor()
30
-    {
27
+    protected static function getFacadeAccessor() {
31 28
         return 'request';
32 29
     }
33 30
 }
Please login to merge, or discard this patch.
vendor/illuminate/support/Arr.php 3 patches
Indentation   +591 added lines, -591 removed lines patch added patch discarded remove patch
@@ -8,595 +8,595 @@
 block discarded – undo
8 8
 
9 9
 class Arr
10 10
 {
11
-    use Macroable;
12
-
13
-    /**
14
-     * Determine whether the given value is array accessible.
15
-     *
16
-     * @param  mixed  $value
17
-     * @return bool
18
-     */
19
-    public static function accessible($value)
20
-    {
21
-        return is_array($value) || $value instanceof ArrayAccess;
22
-    }
23
-
24
-    /**
25
-     * Add an element to an array using "dot" notation if it doesn't exist.
26
-     *
27
-     * @param  array   $array
28
-     * @param  string  $key
29
-     * @param  mixed   $value
30
-     * @return array
31
-     */
32
-    public static function add($array, $key, $value)
33
-    {
34
-        if (is_null(static::get($array, $key))) {
35
-            static::set($array, $key, $value);
36
-        }
37
-
38
-        return $array;
39
-    }
40
-
41
-    /**
42
-     * Collapse an array of arrays into a single array.
43
-     *
44
-     * @param  array  $array
45
-     * @return array
46
-     */
47
-    public static function collapse($array)
48
-    {
49
-        $results = [];
50
-
51
-        foreach ($array as $values) {
52
-            if ($values instanceof Collection) {
53
-                $values = $values->all();
54
-            } elseif (! is_array($values)) {
55
-                continue;
56
-            }
57
-
58
-            $results = array_merge($results, $values);
59
-        }
60
-
61
-        return $results;
62
-    }
63
-
64
-    /**
65
-     * Cross join the given arrays, returning all possible permutations.
66
-     *
67
-     * @param  array  ...$arrays
68
-     * @return array
69
-     */
70
-    public static function crossJoin(...$arrays)
71
-    {
72
-        $results = [[]];
73
-
74
-        foreach ($arrays as $index => $array) {
75
-            $append = [];
76
-
77
-            foreach ($results as $product) {
78
-                foreach ($array as $item) {
79
-                    $product[$index] = $item;
80
-
81
-                    $append[] = $product;
82
-                }
83
-            }
84
-
85
-            $results = $append;
86
-        }
87
-
88
-        return $results;
89
-    }
90
-
91
-    /**
92
-     * Divide an array into two arrays. One with keys and the other with values.
93
-     *
94
-     * @param  array  $array
95
-     * @return array
96
-     */
97
-    public static function divide($array)
98
-    {
99
-        return [array_keys($array), array_values($array)];
100
-    }
101
-
102
-    /**
103
-     * Flatten a multi-dimensional associative array with dots.
104
-     *
105
-     * @param  array   $array
106
-     * @param  string  $prepend
107
-     * @return array
108
-     */
109
-    public static function dot($array, $prepend = '')
110
-    {
111
-        $results = [];
112
-
113
-        foreach ($array as $key => $value) {
114
-            if (is_array($value) && ! empty($value)) {
115
-                $results = array_merge($results, static::dot($value, $prepend.$key.'.'));
116
-            } else {
117
-                $results[$prepend.$key] = $value;
118
-            }
119
-        }
120
-
121
-        return $results;
122
-    }
123
-
124
-    /**
125
-     * Get all of the given array except for a specified array of items.
126
-     *
127
-     * @param  array  $array
128
-     * @param  array|string  $keys
129
-     * @return array
130
-     */
131
-    public static function except($array, $keys)
132
-    {
133
-        static::forget($array, $keys);
134
-
135
-        return $array;
136
-    }
137
-
138
-    /**
139
-     * Determine if the given key exists in the provided array.
140
-     *
141
-     * @param  \ArrayAccess|array  $array
142
-     * @param  string|int  $key
143
-     * @return bool
144
-     */
145
-    public static function exists($array, $key)
146
-    {
147
-        if ($array instanceof ArrayAccess) {
148
-            return $array->offsetExists($key);
149
-        }
150
-
151
-        return array_key_exists($key, $array);
152
-    }
153
-
154
-    /**
155
-     * Return the first element in an array passing a given truth test.
156
-     *
157
-     * @param  array  $array
158
-     * @param  callable|null  $callback
159
-     * @param  mixed  $default
160
-     * @return mixed
161
-     */
162
-    public static function first($array, callable $callback = null, $default = null)
163
-    {
164
-        if (is_null($callback)) {
165
-            if (empty($array)) {
166
-                return value($default);
167
-            }
168
-
169
-            foreach ($array as $item) {
170
-                return $item;
171
-            }
172
-        }
173
-
174
-        foreach ($array as $key => $value) {
175
-            if (call_user_func($callback, $value, $key)) {
176
-                return $value;
177
-            }
178
-        }
179
-
180
-        return value($default);
181
-    }
182
-
183
-    /**
184
-     * Return the last element in an array passing a given truth test.
185
-     *
186
-     * @param  array  $array
187
-     * @param  callable|null  $callback
188
-     * @param  mixed  $default
189
-     * @return mixed
190
-     */
191
-    public static function last($array, callable $callback = null, $default = null)
192
-    {
193
-        if (is_null($callback)) {
194
-            return empty($array) ? value($default) : end($array);
195
-        }
196
-
197
-        return static::first(array_reverse($array, true), $callback, $default);
198
-    }
199
-
200
-    /**
201
-     * Flatten a multi-dimensional array into a single level.
202
-     *
203
-     * @param  array  $array
204
-     * @param  int  $depth
205
-     * @return array
206
-     */
207
-    public static function flatten($array, $depth = INF)
208
-    {
209
-        return array_reduce($array, function ($result, $item) use ($depth) {
210
-            $item = $item instanceof Collection ? $item->all() : $item;
211
-
212
-            if (! is_array($item)) {
213
-                return array_merge($result, [$item]);
214
-            } elseif ($depth === 1) {
215
-                return array_merge($result, array_values($item));
216
-            } else {
217
-                return array_merge($result, static::flatten($item, $depth - 1));
218
-            }
219
-        }, []);
220
-    }
221
-
222
-    /**
223
-     * Remove one or many array items from a given array using "dot" notation.
224
-     *
225
-     * @param  array  $array
226
-     * @param  array|string  $keys
227
-     * @return void
228
-     */
229
-    public static function forget(&$array, $keys)
230
-    {
231
-        $original = &$array;
232
-
233
-        $keys = (array) $keys;
234
-
235
-        if (count($keys) === 0) {
236
-            return;
237
-        }
238
-
239
-        foreach ($keys as $key) {
240
-            // if the exact key exists in the top-level, remove it
241
-            if (static::exists($array, $key)) {
242
-                unset($array[$key]);
243
-
244
-                continue;
245
-            }
246
-
247
-            $parts = explode('.', $key);
248
-
249
-            // clean up before each pass
250
-            $array = &$original;
251
-
252
-            while (count($parts) > 1) {
253
-                $part = array_shift($parts);
254
-
255
-                if (isset($array[$part]) && is_array($array[$part])) {
256
-                    $array = &$array[$part];
257
-                } else {
258
-                    continue 2;
259
-                }
260
-            }
261
-
262
-            unset($array[array_shift($parts)]);
263
-        }
264
-    }
265
-
266
-    /**
267
-     * Get an item from an array using "dot" notation.
268
-     *
269
-     * @param  \ArrayAccess|array  $array
270
-     * @param  string  $key
271
-     * @param  mixed   $default
272
-     * @return mixed
273
-     */
274
-    public static function get($array, $key, $default = null)
275
-    {
276
-        if (! static::accessible($array)) {
277
-            return value($default);
278
-        }
279
-
280
-        if (is_null($key)) {
281
-            return $array;
282
-        }
283
-
284
-        if (static::exists($array, $key)) {
285
-            return $array[$key];
286
-        }
287
-
288
-        foreach (explode('.', $key) as $segment) {
289
-            if (static::accessible($array) && static::exists($array, $segment)) {
290
-                $array = $array[$segment];
291
-            } else {
292
-                return value($default);
293
-            }
294
-        }
295
-
296
-        return $array;
297
-    }
298
-
299
-    /**
300
-     * Check if an item or items exist in an array using "dot" notation.
301
-     *
302
-     * @param  \ArrayAccess|array  $array
303
-     * @param  string|array  $keys
304
-     * @return bool
305
-     */
306
-    public static function has($array, $keys)
307
-    {
308
-        if (is_null($keys)) {
309
-            return false;
310
-        }
311
-
312
-        $keys = (array) $keys;
313
-
314
-        if (! $array) {
315
-            return false;
316
-        }
317
-
318
-        if ($keys === []) {
319
-            return false;
320
-        }
321
-
322
-        foreach ($keys as $key) {
323
-            $subKeyArray = $array;
324
-
325
-            if (static::exists($array, $key)) {
326
-                continue;
327
-            }
328
-
329
-            foreach (explode('.', $key) as $segment) {
330
-                if (static::accessible($subKeyArray) && static::exists($subKeyArray, $segment)) {
331
-                    $subKeyArray = $subKeyArray[$segment];
332
-                } else {
333
-                    return false;
334
-                }
335
-            }
336
-        }
337
-
338
-        return true;
339
-    }
340
-
341
-    /**
342
-     * Determines if an array is associative.
343
-     *
344
-     * An array is "associative" if it doesn't have sequential numerical keys beginning with zero.
345
-     *
346
-     * @param  array  $array
347
-     * @return bool
348
-     */
349
-    public static function isAssoc(array $array)
350
-    {
351
-        $keys = array_keys($array);
352
-
353
-        return array_keys($keys) !== $keys;
354
-    }
355
-
356
-    /**
357
-     * Get a subset of the items from the given array.
358
-     *
359
-     * @param  array  $array
360
-     * @param  array|string  $keys
361
-     * @return array
362
-     */
363
-    public static function only($array, $keys)
364
-    {
365
-        return array_intersect_key($array, array_flip((array) $keys));
366
-    }
367
-
368
-    /**
369
-     * Pluck an array of values from an array.
370
-     *
371
-     * @param  array  $array
372
-     * @param  string|array  $value
373
-     * @param  string|array|null  $key
374
-     * @return array
375
-     */
376
-    public static function pluck($array, $value, $key = null)
377
-    {
378
-        $results = [];
379
-
380
-        list($value, $key) = static::explodePluckParameters($value, $key);
381
-
382
-        foreach ($array as $item) {
383
-            $itemValue = data_get($item, $value);
384
-
385
-            // If the key is "null", we will just append the value to the array and keep
386
-            // looping. Otherwise we will key the array using the value of the key we
387
-            // received from the developer. Then we'll return the final array form.
388
-            if (is_null($key)) {
389
-                $results[] = $itemValue;
390
-            } else {
391
-                $itemKey = data_get($item, $key);
392
-
393
-                if (is_object($itemKey) && method_exists($itemKey, '__toString')) {
394
-                    $itemKey = (string) $itemKey;
395
-                }
396
-
397
-                $results[$itemKey] = $itemValue;
398
-            }
399
-        }
400
-
401
-        return $results;
402
-    }
403
-
404
-    /**
405
-     * Explode the "value" and "key" arguments passed to "pluck".
406
-     *
407
-     * @param  string|array  $value
408
-     * @param  string|array|null  $key
409
-     * @return array
410
-     */
411
-    protected static function explodePluckParameters($value, $key)
412
-    {
413
-        $value = is_string($value) ? explode('.', $value) : $value;
414
-
415
-        $key = is_null($key) || is_array($key) ? $key : explode('.', $key);
416
-
417
-        return [$value, $key];
418
-    }
419
-
420
-    /**
421
-     * Push an item onto the beginning of an array.
422
-     *
423
-     * @param  array  $array
424
-     * @param  mixed  $value
425
-     * @param  mixed  $key
426
-     * @return array
427
-     */
428
-    public static function prepend($array, $value, $key = null)
429
-    {
430
-        if (is_null($key)) {
431
-            array_unshift($array, $value);
432
-        } else {
433
-            $array = [$key => $value] + $array;
434
-        }
435
-
436
-        return $array;
437
-    }
438
-
439
-    /**
440
-     * Get a value from the array, and remove it.
441
-     *
442
-     * @param  array   $array
443
-     * @param  string  $key
444
-     * @param  mixed   $default
445
-     * @return mixed
446
-     */
447
-    public static function pull(&$array, $key, $default = null)
448
-    {
449
-        $value = static::get($array, $key, $default);
450
-
451
-        static::forget($array, $key);
452
-
453
-        return $value;
454
-    }
455
-
456
-    /**
457
-     * Get one or a specified number of random values from an array.
458
-     *
459
-     * @param  array  $array
460
-     * @param  int|null  $number
461
-     * @return mixed
462
-     *
463
-     * @throws \InvalidArgumentException
464
-     */
465
-    public static function random($array, $number = null)
466
-    {
467
-        $requested = is_null($number) ? 1 : $number;
468
-
469
-        $count = count($array);
470
-
471
-        if ($requested > $count) {
472
-            throw new InvalidArgumentException(
473
-                "You requested {$requested} items, but there are only {$count} items available."
474
-            );
475
-        }
476
-
477
-        if (is_null($number)) {
478
-            return $array[array_rand($array)];
479
-        }
480
-
481
-        if ((int) $number === 0) {
482
-            return [];
483
-        }
484
-
485
-        $keys = array_rand($array, $number);
486
-
487
-        $results = [];
488
-
489
-        foreach ((array) $keys as $key) {
490
-            $results[] = $array[$key];
491
-        }
492
-
493
-        return $results;
494
-    }
495
-
496
-    /**
497
-     * Set an array item to a given value using "dot" notation.
498
-     *
499
-     * If no key is given to the method, the entire array will be replaced.
500
-     *
501
-     * @param  array   $array
502
-     * @param  string  $key
503
-     * @param  mixed   $value
504
-     * @return array
505
-     */
506
-    public static function set(&$array, $key, $value)
507
-    {
508
-        if (is_null($key)) {
509
-            return $array = $value;
510
-        }
511
-
512
-        $keys = explode('.', $key);
513
-
514
-        while (count($keys) > 1) {
515
-            $key = array_shift($keys);
516
-
517
-            // If the key doesn't exist at this depth, we will just create an empty array
518
-            // to hold the next value, allowing us to create the arrays to hold final
519
-            // values at the correct depth. Then we'll keep digging into the array.
520
-            if (! isset($array[$key]) || ! is_array($array[$key])) {
521
-                $array[$key] = [];
522
-            }
523
-
524
-            $array = &$array[$key];
525
-        }
526
-
527
-        $array[array_shift($keys)] = $value;
528
-
529
-        return $array;
530
-    }
531
-
532
-    /**
533
-     * Shuffle the given array and return the result.
534
-     *
535
-     * @param  array  $array
536
-     * @return array
537
-     */
538
-    public static function shuffle($array)
539
-    {
540
-        shuffle($array);
541
-
542
-        return $array;
543
-    }
544
-
545
-    /**
546
-     * Sort the array using the given callback or "dot" notation.
547
-     *
548
-     * @param  array  $array
549
-     * @param  callable|string  $callback
550
-     * @return array
551
-     */
552
-    public static function sort($array, $callback)
553
-    {
554
-        return Collection::make($array)->sortBy($callback)->all();
555
-    }
556
-
557
-    /**
558
-     * Recursively sort an array by keys and values.
559
-     *
560
-     * @param  array  $array
561
-     * @return array
562
-     */
563
-    public static function sortRecursive($array)
564
-    {
565
-        foreach ($array as &$value) {
566
-            if (is_array($value)) {
567
-                $value = static::sortRecursive($value);
568
-            }
569
-        }
570
-
571
-        if (static::isAssoc($array)) {
572
-            ksort($array);
573
-        } else {
574
-            sort($array);
575
-        }
576
-
577
-        return $array;
578
-    }
579
-
580
-    /**
581
-     * Filter the array using the given callback.
582
-     *
583
-     * @param  array  $array
584
-     * @param  callable  $callback
585
-     * @return array
586
-     */
587
-    public static function where($array, callable $callback)
588
-    {
589
-        return array_filter($array, $callback, ARRAY_FILTER_USE_BOTH);
590
-    }
591
-
592
-    /**
593
-     * If the given value is not an array, wrap it in one.
594
-     *
595
-     * @param  mixed  $value
596
-     * @return array
597
-     */
598
-    public static function wrap($value)
599
-    {
600
-        return ! is_array($value) ? [$value] : $value;
601
-    }
11
+	use Macroable;
12
+
13
+	/**
14
+	 * Determine whether the given value is array accessible.
15
+	 *
16
+	 * @param  mixed  $value
17
+	 * @return bool
18
+	 */
19
+	public static function accessible($value)
20
+	{
21
+		return is_array($value) || $value instanceof ArrayAccess;
22
+	}
23
+
24
+	/**
25
+	 * Add an element to an array using "dot" notation if it doesn't exist.
26
+	 *
27
+	 * @param  array   $array
28
+	 * @param  string  $key
29
+	 * @param  mixed   $value
30
+	 * @return array
31
+	 */
32
+	public static function add($array, $key, $value)
33
+	{
34
+		if (is_null(static::get($array, $key))) {
35
+			static::set($array, $key, $value);
36
+		}
37
+
38
+		return $array;
39
+	}
40
+
41
+	/**
42
+	 * Collapse an array of arrays into a single array.
43
+	 *
44
+	 * @param  array  $array
45
+	 * @return array
46
+	 */
47
+	public static function collapse($array)
48
+	{
49
+		$results = [];
50
+
51
+		foreach ($array as $values) {
52
+			if ($values instanceof Collection) {
53
+				$values = $values->all();
54
+			} elseif (! is_array($values)) {
55
+				continue;
56
+			}
57
+
58
+			$results = array_merge($results, $values);
59
+		}
60
+
61
+		return $results;
62
+	}
63
+
64
+	/**
65
+	 * Cross join the given arrays, returning all possible permutations.
66
+	 *
67
+	 * @param  array  ...$arrays
68
+	 * @return array
69
+	 */
70
+	public static function crossJoin(...$arrays)
71
+	{
72
+		$results = [[]];
73
+
74
+		foreach ($arrays as $index => $array) {
75
+			$append = [];
76
+
77
+			foreach ($results as $product) {
78
+				foreach ($array as $item) {
79
+					$product[$index] = $item;
80
+
81
+					$append[] = $product;
82
+				}
83
+			}
84
+
85
+			$results = $append;
86
+		}
87
+
88
+		return $results;
89
+	}
90
+
91
+	/**
92
+	 * Divide an array into two arrays. One with keys and the other with values.
93
+	 *
94
+	 * @param  array  $array
95
+	 * @return array
96
+	 */
97
+	public static function divide($array)
98
+	{
99
+		return [array_keys($array), array_values($array)];
100
+	}
101
+
102
+	/**
103
+	 * Flatten a multi-dimensional associative array with dots.
104
+	 *
105
+	 * @param  array   $array
106
+	 * @param  string  $prepend
107
+	 * @return array
108
+	 */
109
+	public static function dot($array, $prepend = '')
110
+	{
111
+		$results = [];
112
+
113
+		foreach ($array as $key => $value) {
114
+			if (is_array($value) && ! empty($value)) {
115
+				$results = array_merge($results, static::dot($value, $prepend.$key.'.'));
116
+			} else {
117
+				$results[$prepend.$key] = $value;
118
+			}
119
+		}
120
+
121
+		return $results;
122
+	}
123
+
124
+	/**
125
+	 * Get all of the given array except for a specified array of items.
126
+	 *
127
+	 * @param  array  $array
128
+	 * @param  array|string  $keys
129
+	 * @return array
130
+	 */
131
+	public static function except($array, $keys)
132
+	{
133
+		static::forget($array, $keys);
134
+
135
+		return $array;
136
+	}
137
+
138
+	/**
139
+	 * Determine if the given key exists in the provided array.
140
+	 *
141
+	 * @param  \ArrayAccess|array  $array
142
+	 * @param  string|int  $key
143
+	 * @return bool
144
+	 */
145
+	public static function exists($array, $key)
146
+	{
147
+		if ($array instanceof ArrayAccess) {
148
+			return $array->offsetExists($key);
149
+		}
150
+
151
+		return array_key_exists($key, $array);
152
+	}
153
+
154
+	/**
155
+	 * Return the first element in an array passing a given truth test.
156
+	 *
157
+	 * @param  array  $array
158
+	 * @param  callable|null  $callback
159
+	 * @param  mixed  $default
160
+	 * @return mixed
161
+	 */
162
+	public static function first($array, callable $callback = null, $default = null)
163
+	{
164
+		if (is_null($callback)) {
165
+			if (empty($array)) {
166
+				return value($default);
167
+			}
168
+
169
+			foreach ($array as $item) {
170
+				return $item;
171
+			}
172
+		}
173
+
174
+		foreach ($array as $key => $value) {
175
+			if (call_user_func($callback, $value, $key)) {
176
+				return $value;
177
+			}
178
+		}
179
+
180
+		return value($default);
181
+	}
182
+
183
+	/**
184
+	 * Return the last element in an array passing a given truth test.
185
+	 *
186
+	 * @param  array  $array
187
+	 * @param  callable|null  $callback
188
+	 * @param  mixed  $default
189
+	 * @return mixed
190
+	 */
191
+	public static function last($array, callable $callback = null, $default = null)
192
+	{
193
+		if (is_null($callback)) {
194
+			return empty($array) ? value($default) : end($array);
195
+		}
196
+
197
+		return static::first(array_reverse($array, true), $callback, $default);
198
+	}
199
+
200
+	/**
201
+	 * Flatten a multi-dimensional array into a single level.
202
+	 *
203
+	 * @param  array  $array
204
+	 * @param  int  $depth
205
+	 * @return array
206
+	 */
207
+	public static function flatten($array, $depth = INF)
208
+	{
209
+		return array_reduce($array, function ($result, $item) use ($depth) {
210
+			$item = $item instanceof Collection ? $item->all() : $item;
211
+
212
+			if (! is_array($item)) {
213
+				return array_merge($result, [$item]);
214
+			} elseif ($depth === 1) {
215
+				return array_merge($result, array_values($item));
216
+			} else {
217
+				return array_merge($result, static::flatten($item, $depth - 1));
218
+			}
219
+		}, []);
220
+	}
221
+
222
+	/**
223
+	 * Remove one or many array items from a given array using "dot" notation.
224
+	 *
225
+	 * @param  array  $array
226
+	 * @param  array|string  $keys
227
+	 * @return void
228
+	 */
229
+	public static function forget(&$array, $keys)
230
+	{
231
+		$original = &$array;
232
+
233
+		$keys = (array) $keys;
234
+
235
+		if (count($keys) === 0) {
236
+			return;
237
+		}
238
+
239
+		foreach ($keys as $key) {
240
+			// if the exact key exists in the top-level, remove it
241
+			if (static::exists($array, $key)) {
242
+				unset($array[$key]);
243
+
244
+				continue;
245
+			}
246
+
247
+			$parts = explode('.', $key);
248
+
249
+			// clean up before each pass
250
+			$array = &$original;
251
+
252
+			while (count($parts) > 1) {
253
+				$part = array_shift($parts);
254
+
255
+				if (isset($array[$part]) && is_array($array[$part])) {
256
+					$array = &$array[$part];
257
+				} else {
258
+					continue 2;
259
+				}
260
+			}
261
+
262
+			unset($array[array_shift($parts)]);
263
+		}
264
+	}
265
+
266
+	/**
267
+	 * Get an item from an array using "dot" notation.
268
+	 *
269
+	 * @param  \ArrayAccess|array  $array
270
+	 * @param  string  $key
271
+	 * @param  mixed   $default
272
+	 * @return mixed
273
+	 */
274
+	public static function get($array, $key, $default = null)
275
+	{
276
+		if (! static::accessible($array)) {
277
+			return value($default);
278
+		}
279
+
280
+		if (is_null($key)) {
281
+			return $array;
282
+		}
283
+
284
+		if (static::exists($array, $key)) {
285
+			return $array[$key];
286
+		}
287
+
288
+		foreach (explode('.', $key) as $segment) {
289
+			if (static::accessible($array) && static::exists($array, $segment)) {
290
+				$array = $array[$segment];
291
+			} else {
292
+				return value($default);
293
+			}
294
+		}
295
+
296
+		return $array;
297
+	}
298
+
299
+	/**
300
+	 * Check if an item or items exist in an array using "dot" notation.
301
+	 *
302
+	 * @param  \ArrayAccess|array  $array
303
+	 * @param  string|array  $keys
304
+	 * @return bool
305
+	 */
306
+	public static function has($array, $keys)
307
+	{
308
+		if (is_null($keys)) {
309
+			return false;
310
+		}
311
+
312
+		$keys = (array) $keys;
313
+
314
+		if (! $array) {
315
+			return false;
316
+		}
317
+
318
+		if ($keys === []) {
319
+			return false;
320
+		}
321
+
322
+		foreach ($keys as $key) {
323
+			$subKeyArray = $array;
324
+
325
+			if (static::exists($array, $key)) {
326
+				continue;
327
+			}
328
+
329
+			foreach (explode('.', $key) as $segment) {
330
+				if (static::accessible($subKeyArray) && static::exists($subKeyArray, $segment)) {
331
+					$subKeyArray = $subKeyArray[$segment];
332
+				} else {
333
+					return false;
334
+				}
335
+			}
336
+		}
337
+
338
+		return true;
339
+	}
340
+
341
+	/**
342
+	 * Determines if an array is associative.
343
+	 *
344
+	 * An array is "associative" if it doesn't have sequential numerical keys beginning with zero.
345
+	 *
346
+	 * @param  array  $array
347
+	 * @return bool
348
+	 */
349
+	public static function isAssoc(array $array)
350
+	{
351
+		$keys = array_keys($array);
352
+
353
+		return array_keys($keys) !== $keys;
354
+	}
355
+
356
+	/**
357
+	 * Get a subset of the items from the given array.
358
+	 *
359
+	 * @param  array  $array
360
+	 * @param  array|string  $keys
361
+	 * @return array
362
+	 */
363
+	public static function only($array, $keys)
364
+	{
365
+		return array_intersect_key($array, array_flip((array) $keys));
366
+	}
367
+
368
+	/**
369
+	 * Pluck an array of values from an array.
370
+	 *
371
+	 * @param  array  $array
372
+	 * @param  string|array  $value
373
+	 * @param  string|array|null  $key
374
+	 * @return array
375
+	 */
376
+	public static function pluck($array, $value, $key = null)
377
+	{
378
+		$results = [];
379
+
380
+		list($value, $key) = static::explodePluckParameters($value, $key);
381
+
382
+		foreach ($array as $item) {
383
+			$itemValue = data_get($item, $value);
384
+
385
+			// If the key is "null", we will just append the value to the array and keep
386
+			// looping. Otherwise we will key the array using the value of the key we
387
+			// received from the developer. Then we'll return the final array form.
388
+			if (is_null($key)) {
389
+				$results[] = $itemValue;
390
+			} else {
391
+				$itemKey = data_get($item, $key);
392
+
393
+				if (is_object($itemKey) && method_exists($itemKey, '__toString')) {
394
+					$itemKey = (string) $itemKey;
395
+				}
396
+
397
+				$results[$itemKey] = $itemValue;
398
+			}
399
+		}
400
+
401
+		return $results;
402
+	}
403
+
404
+	/**
405
+	 * Explode the "value" and "key" arguments passed to "pluck".
406
+	 *
407
+	 * @param  string|array  $value
408
+	 * @param  string|array|null  $key
409
+	 * @return array
410
+	 */
411
+	protected static function explodePluckParameters($value, $key)
412
+	{
413
+		$value = is_string($value) ? explode('.', $value) : $value;
414
+
415
+		$key = is_null($key) || is_array($key) ? $key : explode('.', $key);
416
+
417
+		return [$value, $key];
418
+	}
419
+
420
+	/**
421
+	 * Push an item onto the beginning of an array.
422
+	 *
423
+	 * @param  array  $array
424
+	 * @param  mixed  $value
425
+	 * @param  mixed  $key
426
+	 * @return array
427
+	 */
428
+	public static function prepend($array, $value, $key = null)
429
+	{
430
+		if (is_null($key)) {
431
+			array_unshift($array, $value);
432
+		} else {
433
+			$array = [$key => $value] + $array;
434
+		}
435
+
436
+		return $array;
437
+	}
438
+
439
+	/**
440
+	 * Get a value from the array, and remove it.
441
+	 *
442
+	 * @param  array   $array
443
+	 * @param  string  $key
444
+	 * @param  mixed   $default
445
+	 * @return mixed
446
+	 */
447
+	public static function pull(&$array, $key, $default = null)
448
+	{
449
+		$value = static::get($array, $key, $default);
450
+
451
+		static::forget($array, $key);
452
+
453
+		return $value;
454
+	}
455
+
456
+	/**
457
+	 * Get one or a specified number of random values from an array.
458
+	 *
459
+	 * @param  array  $array
460
+	 * @param  int|null  $number
461
+	 * @return mixed
462
+	 *
463
+	 * @throws \InvalidArgumentException
464
+	 */
465
+	public static function random($array, $number = null)
466
+	{
467
+		$requested = is_null($number) ? 1 : $number;
468
+
469
+		$count = count($array);
470
+
471
+		if ($requested > $count) {
472
+			throw new InvalidArgumentException(
473
+				"You requested {$requested} items, but there are only {$count} items available."
474
+			);
475
+		}
476
+
477
+		if (is_null($number)) {
478
+			return $array[array_rand($array)];
479
+		}
480
+
481
+		if ((int) $number === 0) {
482
+			return [];
483
+		}
484
+
485
+		$keys = array_rand($array, $number);
486
+
487
+		$results = [];
488
+
489
+		foreach ((array) $keys as $key) {
490
+			$results[] = $array[$key];
491
+		}
492
+
493
+		return $results;
494
+	}
495
+
496
+	/**
497
+	 * Set an array item to a given value using "dot" notation.
498
+	 *
499
+	 * If no key is given to the method, the entire array will be replaced.
500
+	 *
501
+	 * @param  array   $array
502
+	 * @param  string  $key
503
+	 * @param  mixed   $value
504
+	 * @return array
505
+	 */
506
+	public static function set(&$array, $key, $value)
507
+	{
508
+		if (is_null($key)) {
509
+			return $array = $value;
510
+		}
511
+
512
+		$keys = explode('.', $key);
513
+
514
+		while (count($keys) > 1) {
515
+			$key = array_shift($keys);
516
+
517
+			// If the key doesn't exist at this depth, we will just create an empty array
518
+			// to hold the next value, allowing us to create the arrays to hold final
519
+			// values at the correct depth. Then we'll keep digging into the array.
520
+			if (! isset($array[$key]) || ! is_array($array[$key])) {
521
+				$array[$key] = [];
522
+			}
523
+
524
+			$array = &$array[$key];
525
+		}
526
+
527
+		$array[array_shift($keys)] = $value;
528
+
529
+		return $array;
530
+	}
531
+
532
+	/**
533
+	 * Shuffle the given array and return the result.
534
+	 *
535
+	 * @param  array  $array
536
+	 * @return array
537
+	 */
538
+	public static function shuffle($array)
539
+	{
540
+		shuffle($array);
541
+
542
+		return $array;
543
+	}
544
+
545
+	/**
546
+	 * Sort the array using the given callback or "dot" notation.
547
+	 *
548
+	 * @param  array  $array
549
+	 * @param  callable|string  $callback
550
+	 * @return array
551
+	 */
552
+	public static function sort($array, $callback)
553
+	{
554
+		return Collection::make($array)->sortBy($callback)->all();
555
+	}
556
+
557
+	/**
558
+	 * Recursively sort an array by keys and values.
559
+	 *
560
+	 * @param  array  $array
561
+	 * @return array
562
+	 */
563
+	public static function sortRecursive($array)
564
+	{
565
+		foreach ($array as &$value) {
566
+			if (is_array($value)) {
567
+				$value = static::sortRecursive($value);
568
+			}
569
+		}
570
+
571
+		if (static::isAssoc($array)) {
572
+			ksort($array);
573
+		} else {
574
+			sort($array);
575
+		}
576
+
577
+		return $array;
578
+	}
579
+
580
+	/**
581
+	 * Filter the array using the given callback.
582
+	 *
583
+	 * @param  array  $array
584
+	 * @param  callable  $callback
585
+	 * @return array
586
+	 */
587
+	public static function where($array, callable $callback)
588
+	{
589
+		return array_filter($array, $callback, ARRAY_FILTER_USE_BOTH);
590
+	}
591
+
592
+	/**
593
+	 * If the given value is not an array, wrap it in one.
594
+	 *
595
+	 * @param  mixed  $value
596
+	 * @return array
597
+	 */
598
+	public static function wrap($value)
599
+	{
600
+		return ! is_array($value) ? [$value] : $value;
601
+	}
602 602
 }
Please login to merge, or discard this patch.
Spacing   +148 added lines, -148 removed lines patch added patch discarded remove patch
@@ -16,9 +16,9 @@  discard block
 block discarded – undo
16 16
      * @param  mixed  $value
17 17
      * @return bool
18 18
      */
19
-    public static function accessible($value)
19
+    public static function accessible( $value )
20 20
     {
21
-        return is_array($value) || $value instanceof ArrayAccess;
21
+        return is_array( $value ) || $value instanceof ArrayAccess;
22 22
     }
23 23
 
24 24
     /**
@@ -29,10 +29,10 @@  discard block
 block discarded – undo
29 29
      * @param  mixed   $value
30 30
      * @return array
31 31
      */
32
-    public static function add($array, $key, $value)
32
+    public static function add( $array, $key, $value )
33 33
     {
34
-        if (is_null(static::get($array, $key))) {
35
-            static::set($array, $key, $value);
34
+        if ( is_null( static::get( $array, $key ) ) ) {
35
+            static::set( $array, $key, $value );
36 36
         }
37 37
 
38 38
         return $array;
@@ -44,18 +44,18 @@  discard block
 block discarded – undo
44 44
      * @param  array  $array
45 45
      * @return array
46 46
      */
47
-    public static function collapse($array)
47
+    public static function collapse( $array )
48 48
     {
49
-        $results = [];
49
+        $results = [ ];
50 50
 
51
-        foreach ($array as $values) {
52
-            if ($values instanceof Collection) {
51
+        foreach ( $array as $values ) {
52
+            if ( $values instanceof Collection ) {
53 53
                 $values = $values->all();
54
-            } elseif (! is_array($values)) {
54
+            } elseif ( ! is_array( $values ) ) {
55 55
                 continue;
56 56
             }
57 57
 
58
-            $results = array_merge($results, $values);
58
+            $results = array_merge( $results, $values );
59 59
         }
60 60
 
61 61
         return $results;
@@ -67,18 +67,18 @@  discard block
 block discarded – undo
67 67
      * @param  array  ...$arrays
68 68
      * @return array
69 69
      */
70
-    public static function crossJoin(...$arrays)
70
+    public static function crossJoin( ...$arrays )
71 71
     {
72
-        $results = [[]];
72
+        $results = [ [ ] ];
73 73
 
74
-        foreach ($arrays as $index => $array) {
75
-            $append = [];
74
+        foreach ( $arrays as $index => $array ) {
75
+            $append = [ ];
76 76
 
77
-            foreach ($results as $product) {
78
-                foreach ($array as $item) {
79
-                    $product[$index] = $item;
77
+            foreach ( $results as $product ) {
78
+                foreach ( $array as $item ) {
79
+                    $product[ $index ] = $item;
80 80
 
81
-                    $append[] = $product;
81
+                    $append[ ] = $product;
82 82
                 }
83 83
             }
84 84
 
@@ -94,9 +94,9 @@  discard block
 block discarded – undo
94 94
      * @param  array  $array
95 95
      * @return array
96 96
      */
97
-    public static function divide($array)
97
+    public static function divide( $array )
98 98
     {
99
-        return [array_keys($array), array_values($array)];
99
+        return [ array_keys( $array ), array_values( $array ) ];
100 100
     }
101 101
 
102 102
     /**
@@ -106,15 +106,15 @@  discard block
 block discarded – undo
106 106
      * @param  string  $prepend
107 107
      * @return array
108 108
      */
109
-    public static function dot($array, $prepend = '')
109
+    public static function dot( $array, $prepend = '' )
110 110
     {
111
-        $results = [];
111
+        $results = [ ];
112 112
 
113
-        foreach ($array as $key => $value) {
114
-            if (is_array($value) && ! empty($value)) {
115
-                $results = array_merge($results, static::dot($value, $prepend.$key.'.'));
113
+        foreach ( $array as $key => $value ) {
114
+            if ( is_array( $value ) && ! empty( $value ) ) {
115
+                $results = array_merge( $results, static::dot( $value, $prepend . $key . '.' ) );
116 116
             } else {
117
-                $results[$prepend.$key] = $value;
117
+                $results[ $prepend . $key ] = $value;
118 118
             }
119 119
         }
120 120
 
@@ -128,9 +128,9 @@  discard block
 block discarded – undo
128 128
      * @param  array|string  $keys
129 129
      * @return array
130 130
      */
131
-    public static function except($array, $keys)
131
+    public static function except( $array, $keys )
132 132
     {
133
-        static::forget($array, $keys);
133
+        static::forget( $array, $keys );
134 134
 
135 135
         return $array;
136 136
     }
@@ -142,13 +142,13 @@  discard block
 block discarded – undo
142 142
      * @param  string|int  $key
143 143
      * @return bool
144 144
      */
145
-    public static function exists($array, $key)
145
+    public static function exists( $array, $key )
146 146
     {
147
-        if ($array instanceof ArrayAccess) {
148
-            return $array->offsetExists($key);
147
+        if ( $array instanceof ArrayAccess ) {
148
+            return $array->offsetExists( $key );
149 149
         }
150 150
 
151
-        return array_key_exists($key, $array);
151
+        return array_key_exists( $key, $array );
152 152
     }
153 153
 
154 154
     /**
@@ -159,25 +159,25 @@  discard block
 block discarded – undo
159 159
      * @param  mixed  $default
160 160
      * @return mixed
161 161
      */
162
-    public static function first($array, callable $callback = null, $default = null)
162
+    public static function first( $array, callable $callback = null, $default = null )
163 163
     {
164
-        if (is_null($callback)) {
165
-            if (empty($array)) {
166
-                return value($default);
164
+        if ( is_null( $callback ) ) {
165
+            if ( empty( $array ) ) {
166
+                return value( $default );
167 167
             }
168 168
 
169
-            foreach ($array as $item) {
169
+            foreach ( $array as $item ) {
170 170
                 return $item;
171 171
             }
172 172
         }
173 173
 
174
-        foreach ($array as $key => $value) {
175
-            if (call_user_func($callback, $value, $key)) {
174
+        foreach ( $array as $key => $value ) {
175
+            if ( call_user_func( $callback, $value, $key ) ) {
176 176
                 return $value;
177 177
             }
178 178
         }
179 179
 
180
-        return value($default);
180
+        return value( $default );
181 181
     }
182 182
 
183 183
     /**
@@ -188,13 +188,13 @@  discard block
 block discarded – undo
188 188
      * @param  mixed  $default
189 189
      * @return mixed
190 190
      */
191
-    public static function last($array, callable $callback = null, $default = null)
191
+    public static function last( $array, callable $callback = null, $default = null )
192 192
     {
193
-        if (is_null($callback)) {
194
-            return empty($array) ? value($default) : end($array);
193
+        if ( is_null( $callback ) ) {
194
+            return empty( $array ) ? value( $default ) : end( $array );
195 195
         }
196 196
 
197
-        return static::first(array_reverse($array, true), $callback, $default);
197
+        return static::first( array_reverse( $array, true ), $callback, $default );
198 198
     }
199 199
 
200 200
     /**
@@ -204,19 +204,19 @@  discard block
 block discarded – undo
204 204
      * @param  int  $depth
205 205
      * @return array
206 206
      */
207
-    public static function flatten($array, $depth = INF)
207
+    public static function flatten( $array, $depth = INF )
208 208
     {
209
-        return array_reduce($array, function ($result, $item) use ($depth) {
209
+        return array_reduce( $array, function( $result, $item ) use ( $depth ) {
210 210
             $item = $item instanceof Collection ? $item->all() : $item;
211 211
 
212
-            if (! is_array($item)) {
213
-                return array_merge($result, [$item]);
214
-            } elseif ($depth === 1) {
215
-                return array_merge($result, array_values($item));
212
+            if ( ! is_array( $item ) ) {
213
+                return array_merge( $result, [ $item ] );
214
+            } elseif ( $depth === 1 ) {
215
+                return array_merge( $result, array_values( $item ) );
216 216
             } else {
217
-                return array_merge($result, static::flatten($item, $depth - 1));
217
+                return array_merge( $result, static::flatten( $item, $depth - 1 ) );
218 218
             }
219
-        }, []);
219
+        }, [ ] );
220 220
     }
221 221
 
222 222
     /**
@@ -226,40 +226,40 @@  discard block
 block discarded – undo
226 226
      * @param  array|string  $keys
227 227
      * @return void
228 228
      */
229
-    public static function forget(&$array, $keys)
229
+    public static function forget( &$array, $keys )
230 230
     {
231 231
         $original = &$array;
232 232
 
233
-        $keys = (array) $keys;
233
+        $keys = (array)$keys;
234 234
 
235
-        if (count($keys) === 0) {
235
+        if ( count( $keys ) === 0 ) {
236 236
             return;
237 237
         }
238 238
 
239
-        foreach ($keys as $key) {
239
+        foreach ( $keys as $key ) {
240 240
             // if the exact key exists in the top-level, remove it
241
-            if (static::exists($array, $key)) {
242
-                unset($array[$key]);
241
+            if ( static::exists( $array, $key ) ) {
242
+                unset( $array[ $key ] );
243 243
 
244 244
                 continue;
245 245
             }
246 246
 
247
-            $parts = explode('.', $key);
247
+            $parts = explode( '.', $key );
248 248
 
249 249
             // clean up before each pass
250 250
             $array = &$original;
251 251
 
252
-            while (count($parts) > 1) {
253
-                $part = array_shift($parts);
252
+            while ( count( $parts ) > 1 ) {
253
+                $part = array_shift( $parts );
254 254
 
255
-                if (isset($array[$part]) && is_array($array[$part])) {
256
-                    $array = &$array[$part];
255
+                if ( isset( $array[ $part ] ) && is_array( $array[ $part ] ) ) {
256
+                    $array = &$array[ $part ];
257 257
                 } else {
258 258
                     continue 2;
259 259
                 }
260 260
             }
261 261
 
262
-            unset($array[array_shift($parts)]);
262
+            unset( $array[ array_shift( $parts ) ] );
263 263
         }
264 264
     }
265 265
 
@@ -271,25 +271,25 @@  discard block
 block discarded – undo
271 271
      * @param  mixed   $default
272 272
      * @return mixed
273 273
      */
274
-    public static function get($array, $key, $default = null)
274
+    public static function get( $array, $key, $default = null )
275 275
     {
276
-        if (! static::accessible($array)) {
277
-            return value($default);
276
+        if ( ! static::accessible( $array ) ) {
277
+            return value( $default );
278 278
         }
279 279
 
280
-        if (is_null($key)) {
280
+        if ( is_null( $key ) ) {
281 281
             return $array;
282 282
         }
283 283
 
284
-        if (static::exists($array, $key)) {
285
-            return $array[$key];
284
+        if ( static::exists( $array, $key ) ) {
285
+            return $array[ $key ];
286 286
         }
287 287
 
288
-        foreach (explode('.', $key) as $segment) {
289
-            if (static::accessible($array) && static::exists($array, $segment)) {
290
-                $array = $array[$segment];
288
+        foreach ( explode( '.', $key ) as $segment ) {
289
+            if ( static::accessible( $array ) && static::exists( $array, $segment ) ) {
290
+                $array = $array[ $segment ];
291 291
             } else {
292
-                return value($default);
292
+                return value( $default );
293 293
             }
294 294
         }
295 295
 
@@ -303,32 +303,32 @@  discard block
 block discarded – undo
303 303
      * @param  string|array  $keys
304 304
      * @return bool
305 305
      */
306
-    public static function has($array, $keys)
306
+    public static function has( $array, $keys )
307 307
     {
308
-        if (is_null($keys)) {
308
+        if ( is_null( $keys ) ) {
309 309
             return false;
310 310
         }
311 311
 
312
-        $keys = (array) $keys;
312
+        $keys = (array)$keys;
313 313
 
314
-        if (! $array) {
314
+        if ( ! $array ) {
315 315
             return false;
316 316
         }
317 317
 
318
-        if ($keys === []) {
318
+        if ( $keys === [ ] ) {
319 319
             return false;
320 320
         }
321 321
 
322
-        foreach ($keys as $key) {
322
+        foreach ( $keys as $key ) {
323 323
             $subKeyArray = $array;
324 324
 
325
-            if (static::exists($array, $key)) {
325
+            if ( static::exists( $array, $key ) ) {
326 326
                 continue;
327 327
             }
328 328
 
329
-            foreach (explode('.', $key) as $segment) {
330
-                if (static::accessible($subKeyArray) && static::exists($subKeyArray, $segment)) {
331
-                    $subKeyArray = $subKeyArray[$segment];
329
+            foreach ( explode( '.', $key ) as $segment ) {
330
+                if ( static::accessible( $subKeyArray ) && static::exists( $subKeyArray, $segment ) ) {
331
+                    $subKeyArray = $subKeyArray[ $segment ];
332 332
                 } else {
333 333
                     return false;
334 334
                 }
@@ -346,11 +346,11 @@  discard block
 block discarded – undo
346 346
      * @param  array  $array
347 347
      * @return bool
348 348
      */
349
-    public static function isAssoc(array $array)
349
+    public static function isAssoc( array $array )
350 350
     {
351
-        $keys = array_keys($array);
351
+        $keys = array_keys( $array );
352 352
 
353
-        return array_keys($keys) !== $keys;
353
+        return array_keys( $keys ) !== $keys;
354 354
     }
355 355
 
356 356
     /**
@@ -360,9 +360,9 @@  discard block
 block discarded – undo
360 360
      * @param  array|string  $keys
361 361
      * @return array
362 362
      */
363
-    public static function only($array, $keys)
363
+    public static function only( $array, $keys )
364 364
     {
365
-        return array_intersect_key($array, array_flip((array) $keys));
365
+        return array_intersect_key( $array, array_flip( (array)$keys ) );
366 366
     }
367 367
 
368 368
     /**
@@ -373,28 +373,28 @@  discard block
 block discarded – undo
373 373
      * @param  string|array|null  $key
374 374
      * @return array
375 375
      */
376
-    public static function pluck($array, $value, $key = null)
376
+    public static function pluck( $array, $value, $key = null )
377 377
     {
378
-        $results = [];
378
+        $results = [ ];
379 379
 
380
-        list($value, $key) = static::explodePluckParameters($value, $key);
380
+        list( $value, $key ) = static::explodePluckParameters( $value, $key );
381 381
 
382
-        foreach ($array as $item) {
383
-            $itemValue = data_get($item, $value);
382
+        foreach ( $array as $item ) {
383
+            $itemValue = data_get( $item, $value );
384 384
 
385 385
             // If the key is "null", we will just append the value to the array and keep
386 386
             // looping. Otherwise we will key the array using the value of the key we
387 387
             // received from the developer. Then we'll return the final array form.
388
-            if (is_null($key)) {
389
-                $results[] = $itemValue;
388
+            if ( is_null( $key ) ) {
389
+                $results[ ] = $itemValue;
390 390
             } else {
391
-                $itemKey = data_get($item, $key);
391
+                $itemKey = data_get( $item, $key );
392 392
 
393
-                if (is_object($itemKey) && method_exists($itemKey, '__toString')) {
394
-                    $itemKey = (string) $itemKey;
393
+                if ( is_object( $itemKey ) && method_exists( $itemKey, '__toString' ) ) {
394
+                    $itemKey = (string)$itemKey;
395 395
                 }
396 396
 
397
-                $results[$itemKey] = $itemValue;
397
+                $results[ $itemKey ] = $itemValue;
398 398
             }
399 399
         }
400 400
 
@@ -408,13 +408,13 @@  discard block
 block discarded – undo
408 408
      * @param  string|array|null  $key
409 409
      * @return array
410 410
      */
411
-    protected static function explodePluckParameters($value, $key)
411
+    protected static function explodePluckParameters( $value, $key )
412 412
     {
413
-        $value = is_string($value) ? explode('.', $value) : $value;
413
+        $value = is_string( $value ) ? explode( '.', $value ) : $value;
414 414
 
415
-        $key = is_null($key) || is_array($key) ? $key : explode('.', $key);
415
+        $key = is_null( $key ) || is_array( $key ) ? $key : explode( '.', $key );
416 416
 
417
-        return [$value, $key];
417
+        return [ $value, $key ];
418 418
     }
419 419
 
420 420
     /**
@@ -425,12 +425,12 @@  discard block
 block discarded – undo
425 425
      * @param  mixed  $key
426 426
      * @return array
427 427
      */
428
-    public static function prepend($array, $value, $key = null)
428
+    public static function prepend( $array, $value, $key = null )
429 429
     {
430
-        if (is_null($key)) {
431
-            array_unshift($array, $value);
430
+        if ( is_null( $key ) ) {
431
+            array_unshift( $array, $value );
432 432
         } else {
433
-            $array = [$key => $value] + $array;
433
+            $array = [ $key => $value ] + $array;
434 434
         }
435 435
 
436 436
         return $array;
@@ -444,11 +444,11 @@  discard block
 block discarded – undo
444 444
      * @param  mixed   $default
445 445
      * @return mixed
446 446
      */
447
-    public static function pull(&$array, $key, $default = null)
447
+    public static function pull( &$array, $key, $default = null )
448 448
     {
449
-        $value = static::get($array, $key, $default);
449
+        $value = static::get( $array, $key, $default );
450 450
 
451
-        static::forget($array, $key);
451
+        static::forget( $array, $key );
452 452
 
453 453
         return $value;
454 454
     }
@@ -462,32 +462,32 @@  discard block
 block discarded – undo
462 462
      *
463 463
      * @throws \InvalidArgumentException
464 464
      */
465
-    public static function random($array, $number = null)
465
+    public static function random( $array, $number = null )
466 466
     {
467
-        $requested = is_null($number) ? 1 : $number;
467
+        $requested = is_null( $number ) ? 1 : $number;
468 468
 
469
-        $count = count($array);
469
+        $count = count( $array );
470 470
 
471
-        if ($requested > $count) {
471
+        if ( $requested > $count ) {
472 472
             throw new InvalidArgumentException(
473 473
                 "You requested {$requested} items, but there are only {$count} items available."
474 474
             );
475 475
         }
476 476
 
477
-        if (is_null($number)) {
478
-            return $array[array_rand($array)];
477
+        if ( is_null( $number ) ) {
478
+            return $array[ array_rand( $array ) ];
479 479
         }
480 480
 
481
-        if ((int) $number === 0) {
482
-            return [];
481
+        if ( (int)$number === 0 ) {
482
+            return [ ];
483 483
         }
484 484
 
485
-        $keys = array_rand($array, $number);
485
+        $keys = array_rand( $array, $number );
486 486
 
487
-        $results = [];
487
+        $results = [ ];
488 488
 
489
-        foreach ((array) $keys as $key) {
490
-            $results[] = $array[$key];
489
+        foreach ( (array)$keys as $key ) {
490
+            $results[ ] = $array[ $key ];
491 491
         }
492 492
 
493 493
         return $results;
@@ -503,28 +503,28 @@  discard block
 block discarded – undo
503 503
      * @param  mixed   $value
504 504
      * @return array
505 505
      */
506
-    public static function set(&$array, $key, $value)
506
+    public static function set( &$array, $key, $value )
507 507
     {
508
-        if (is_null($key)) {
508
+        if ( is_null( $key ) ) {
509 509
             return $array = $value;
510 510
         }
511 511
 
512
-        $keys = explode('.', $key);
512
+        $keys = explode( '.', $key );
513 513
 
514
-        while (count($keys) > 1) {
515
-            $key = array_shift($keys);
514
+        while ( count( $keys ) > 1 ) {
515
+            $key = array_shift( $keys );
516 516
 
517 517
             // If the key doesn't exist at this depth, we will just create an empty array
518 518
             // to hold the next value, allowing us to create the arrays to hold final
519 519
             // values at the correct depth. Then we'll keep digging into the array.
520
-            if (! isset($array[$key]) || ! is_array($array[$key])) {
521
-                $array[$key] = [];
520
+            if ( ! isset( $array[ $key ] ) || ! is_array( $array[ $key ] ) ) {
521
+                $array[ $key ] = [ ];
522 522
             }
523 523
 
524
-            $array = &$array[$key];
524
+            $array = &$array[ $key ];
525 525
         }
526 526
 
527
-        $array[array_shift($keys)] = $value;
527
+        $array[ array_shift( $keys ) ] = $value;
528 528
 
529 529
         return $array;
530 530
     }
@@ -535,9 +535,9 @@  discard block
 block discarded – undo
535 535
      * @param  array  $array
536 536
      * @return array
537 537
      */
538
-    public static function shuffle($array)
538
+    public static function shuffle( $array )
539 539
     {
540
-        shuffle($array);
540
+        shuffle( $array );
541 541
 
542 542
         return $array;
543 543
     }
@@ -549,9 +549,9 @@  discard block
 block discarded – undo
549 549
      * @param  callable|string  $callback
550 550
      * @return array
551 551
      */
552
-    public static function sort($array, $callback)
552
+    public static function sort( $array, $callback )
553 553
     {
554
-        return Collection::make($array)->sortBy($callback)->all();
554
+        return Collection::make( $array )->sortBy( $callback )->all();
555 555
     }
556 556
 
557 557
     /**
@@ -560,18 +560,18 @@  discard block
 block discarded – undo
560 560
      * @param  array  $array
561 561
      * @return array
562 562
      */
563
-    public static function sortRecursive($array)
563
+    public static function sortRecursive( $array )
564 564
     {
565
-        foreach ($array as &$value) {
566
-            if (is_array($value)) {
567
-                $value = static::sortRecursive($value);
565
+        foreach ( $array as &$value ) {
566
+            if ( is_array( $value ) ) {
567
+                $value = static::sortRecursive( $value );
568 568
             }
569 569
         }
570 570
 
571
-        if (static::isAssoc($array)) {
572
-            ksort($array);
571
+        if ( static::isAssoc( $array ) ) {
572
+            ksort( $array );
573 573
         } else {
574
-            sort($array);
574
+            sort( $array );
575 575
         }
576 576
 
577 577
         return $array;
@@ -584,9 +584,9 @@  discard block
 block discarded – undo
584 584
      * @param  callable  $callback
585 585
      * @return array
586 586
      */
587
-    public static function where($array, callable $callback)
587
+    public static function where( $array, callable $callback )
588 588
     {
589
-        return array_filter($array, $callback, ARRAY_FILTER_USE_BOTH);
589
+        return array_filter( $array, $callback, ARRAY_FILTER_USE_BOTH );
590 590
     }
591 591
 
592 592
     /**
@@ -595,8 +595,8 @@  discard block
 block discarded – undo
595 595
      * @param  mixed  $value
596 596
      * @return array
597 597
      */
598
-    public static function wrap($value)
598
+    public static function wrap( $value )
599 599
     {
600
-        return ! is_array($value) ? [$value] : $value;
600
+        return ! is_array( $value ) ? [ $value ] : $value;
601 601
     }
602 602
 }
Please login to merge, or discard this patch.
Braces   +28 added lines, -56 removed lines patch added patch discarded remove patch
@@ -6,8 +6,7 @@  discard block
 block discarded – undo
6 6
 use InvalidArgumentException;
7 7
 use Illuminate\Support\Traits\Macroable;
8 8
 
9
-class Arr
10
-{
9
+class Arr {
11 10
     use Macroable;
12 11
 
13 12
     /**
@@ -16,8 +15,7 @@  discard block
 block discarded – undo
16 15
      * @param  mixed  $value
17 16
      * @return bool
18 17
      */
19
-    public static function accessible($value)
20
-    {
18
+    public static function accessible($value) {
21 19
         return is_array($value) || $value instanceof ArrayAccess;
22 20
     }
23 21
 
@@ -29,8 +27,7 @@  discard block
 block discarded – undo
29 27
      * @param  mixed   $value
30 28
      * @return array
31 29
      */
32
-    public static function add($array, $key, $value)
33
-    {
30
+    public static function add($array, $key, $value) {
34 31
         if (is_null(static::get($array, $key))) {
35 32
             static::set($array, $key, $value);
36 33
         }
@@ -44,8 +41,7 @@  discard block
 block discarded – undo
44 41
      * @param  array  $array
45 42
      * @return array
46 43
      */
47
-    public static function collapse($array)
48
-    {
44
+    public static function collapse($array) {
49 45
         $results = [];
50 46
 
51 47
         foreach ($array as $values) {
@@ -67,8 +63,7 @@  discard block
 block discarded – undo
67 63
      * @param  array  ...$arrays
68 64
      * @return array
69 65
      */
70
-    public static function crossJoin(...$arrays)
71
-    {
66
+    public static function crossJoin(...$arrays) {
72 67
         $results = [[]];
73 68
 
74 69
         foreach ($arrays as $index => $array) {
@@ -94,8 +89,7 @@  discard block
 block discarded – undo
94 89
      * @param  array  $array
95 90
      * @return array
96 91
      */
97
-    public static function divide($array)
98
-    {
92
+    public static function divide($array) {
99 93
         return [array_keys($array), array_values($array)];
100 94
     }
101 95
 
@@ -106,8 +100,7 @@  discard block
 block discarded – undo
106 100
      * @param  string  $prepend
107 101
      * @return array
108 102
      */
109
-    public static function dot($array, $prepend = '')
110
-    {
103
+    public static function dot($array, $prepend = '') {
111 104
         $results = [];
112 105
 
113 106
         foreach ($array as $key => $value) {
@@ -128,8 +121,7 @@  discard block
 block discarded – undo
128 121
      * @param  array|string  $keys
129 122
      * @return array
130 123
      */
131
-    public static function except($array, $keys)
132
-    {
124
+    public static function except($array, $keys) {
133 125
         static::forget($array, $keys);
134 126
 
135 127
         return $array;
@@ -142,8 +134,7 @@  discard block
 block discarded – undo
142 134
      * @param  string|int  $key
143 135
      * @return bool
144 136
      */
145
-    public static function exists($array, $key)
146
-    {
137
+    public static function exists($array, $key) {
147 138
         if ($array instanceof ArrayAccess) {
148 139
             return $array->offsetExists($key);
149 140
         }
@@ -159,8 +150,7 @@  discard block
 block discarded – undo
159 150
      * @param  mixed  $default
160 151
      * @return mixed
161 152
      */
162
-    public static function first($array, callable $callback = null, $default = null)
163
-    {
153
+    public static function first($array, callable $callback = null, $default = null) {
164 154
         if (is_null($callback)) {
165 155
             if (empty($array)) {
166 156
                 return value($default);
@@ -188,8 +178,7 @@  discard block
 block discarded – undo
188 178
      * @param  mixed  $default
189 179
      * @return mixed
190 180
      */
191
-    public static function last($array, callable $callback = null, $default = null)
192
-    {
181
+    public static function last($array, callable $callback = null, $default = null) {
193 182
         if (is_null($callback)) {
194 183
             return empty($array) ? value($default) : end($array);
195 184
         }
@@ -204,8 +193,7 @@  discard block
 block discarded – undo
204 193
      * @param  int  $depth
205 194
      * @return array
206 195
      */
207
-    public static function flatten($array, $depth = INF)
208
-    {
196
+    public static function flatten($array, $depth = INF) {
209 197
         return array_reduce($array, function ($result, $item) use ($depth) {
210 198
             $item = $item instanceof Collection ? $item->all() : $item;
211 199
 
@@ -226,8 +214,7 @@  discard block
 block discarded – undo
226 214
      * @param  array|string  $keys
227 215
      * @return void
228 216
      */
229
-    public static function forget(&$array, $keys)
230
-    {
217
+    public static function forget(&$array, $keys) {
231 218
         $original = &$array;
232 219
 
233 220
         $keys = (array) $keys;
@@ -271,8 +258,7 @@  discard block
 block discarded – undo
271 258
      * @param  mixed   $default
272 259
      * @return mixed
273 260
      */
274
-    public static function get($array, $key, $default = null)
275
-    {
261
+    public static function get($array, $key, $default = null) {
276 262
         if (! static::accessible($array)) {
277 263
             return value($default);
278 264
         }
@@ -303,8 +289,7 @@  discard block
 block discarded – undo
303 289
      * @param  string|array  $keys
304 290
      * @return bool
305 291
      */
306
-    public static function has($array, $keys)
307
-    {
292
+    public static function has($array, $keys) {
308 293
         if (is_null($keys)) {
309 294
             return false;
310 295
         }
@@ -346,8 +331,7 @@  discard block
 block discarded – undo
346 331
      * @param  array  $array
347 332
      * @return bool
348 333
      */
349
-    public static function isAssoc(array $array)
350
-    {
334
+    public static function isAssoc(array $array) {
351 335
         $keys = array_keys($array);
352 336
 
353 337
         return array_keys($keys) !== $keys;
@@ -360,8 +344,7 @@  discard block
 block discarded – undo
360 344
      * @param  array|string  $keys
361 345
      * @return array
362 346
      */
363
-    public static function only($array, $keys)
364
-    {
347
+    public static function only($array, $keys) {
365 348
         return array_intersect_key($array, array_flip((array) $keys));
366 349
     }
367 350
 
@@ -373,8 +356,7 @@  discard block
 block discarded – undo
373 356
      * @param  string|array|null  $key
374 357
      * @return array
375 358
      */
376
-    public static function pluck($array, $value, $key = null)
377
-    {
359
+    public static function pluck($array, $value, $key = null) {
378 360
         $results = [];
379 361
 
380 362
         list($value, $key) = static::explodePluckParameters($value, $key);
@@ -408,8 +390,7 @@  discard block
 block discarded – undo
408 390
      * @param  string|array|null  $key
409 391
      * @return array
410 392
      */
411
-    protected static function explodePluckParameters($value, $key)
412
-    {
393
+    protected static function explodePluckParameters($value, $key) {
413 394
         $value = is_string($value) ? explode('.', $value) : $value;
414 395
 
415 396
         $key = is_null($key) || is_array($key) ? $key : explode('.', $key);
@@ -425,8 +406,7 @@  discard block
 block discarded – undo
425 406
      * @param  mixed  $key
426 407
      * @return array
427 408
      */
428
-    public static function prepend($array, $value, $key = null)
429
-    {
409
+    public static function prepend($array, $value, $key = null) {
430 410
         if (is_null($key)) {
431 411
             array_unshift($array, $value);
432 412
         } else {
@@ -444,8 +424,7 @@  discard block
 block discarded – undo
444 424
      * @param  mixed   $default
445 425
      * @return mixed
446 426
      */
447
-    public static function pull(&$array, $key, $default = null)
448
-    {
427
+    public static function pull(&$array, $key, $default = null) {
449 428
         $value = static::get($array, $key, $default);
450 429
 
451 430
         static::forget($array, $key);
@@ -462,8 +441,7 @@  discard block
 block discarded – undo
462 441
      *
463 442
      * @throws \InvalidArgumentException
464 443
      */
465
-    public static function random($array, $number = null)
466
-    {
444
+    public static function random($array, $number = null) {
467 445
         $requested = is_null($number) ? 1 : $number;
468 446
 
469 447
         $count = count($array);
@@ -503,8 +481,7 @@  discard block
 block discarded – undo
503 481
      * @param  mixed   $value
504 482
      * @return array
505 483
      */
506
-    public static function set(&$array, $key, $value)
507
-    {
484
+    public static function set(&$array, $key, $value) {
508 485
         if (is_null($key)) {
509 486
             return $array = $value;
510 487
         }
@@ -535,8 +512,7 @@  discard block
 block discarded – undo
535 512
      * @param  array  $array
536 513
      * @return array
537 514
      */
538
-    public static function shuffle($array)
539
-    {
515
+    public static function shuffle($array) {
540 516
         shuffle($array);
541 517
 
542 518
         return $array;
@@ -549,8 +525,7 @@  discard block
 block discarded – undo
549 525
      * @param  callable|string  $callback
550 526
      * @return array
551 527
      */
552
-    public static function sort($array, $callback)
553
-    {
528
+    public static function sort($array, $callback) {
554 529
         return Collection::make($array)->sortBy($callback)->all();
555 530
     }
556 531
 
@@ -560,8 +535,7 @@  discard block
 block discarded – undo
560 535
      * @param  array  $array
561 536
      * @return array
562 537
      */
563
-    public static function sortRecursive($array)
564
-    {
538
+    public static function sortRecursive($array) {
565 539
         foreach ($array as &$value) {
566 540
             if (is_array($value)) {
567 541
                 $value = static::sortRecursive($value);
@@ -584,8 +558,7 @@  discard block
 block discarded – undo
584 558
      * @param  callable  $callback
585 559
      * @return array
586 560
      */
587
-    public static function where($array, callable $callback)
588
-    {
561
+    public static function where($array, callable $callback) {
589 562
         return array_filter($array, $callback, ARRAY_FILTER_USE_BOTH);
590 563
     }
591 564
 
@@ -595,8 +568,7 @@  discard block
 block discarded – undo
595 568
      * @param  mixed  $value
596 569
      * @return array
597 570
      */
598
-    public static function wrap($value)
599
-    {
571
+    public static function wrap($value) {
600 572
         return ! is_array($value) ? [$value] : $value;
601 573
     }
602 574
 }
Please login to merge, or discard this patch.
vendor/illuminate/support/Debug/HtmlDumper.php 2 patches
Indentation   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -6,24 +6,24 @@
 block discarded – undo
6 6
 
7 7
 class HtmlDumper extends SymfonyHtmlDumper
8 8
 {
9
-    /**
10
-     * Colour definitions for output.
11
-     *
12
-     * @var array
13
-     */
14
-    protected $styles = [
15
-        'default' => 'background-color:#fff; color:#222; line-height:1.2em; font-weight:normal; font:12px Monaco, Consolas, monospace; word-wrap: break-word; white-space: pre-wrap; position:relative; z-index:100000',
16
-        'num' => 'color:#a71d5d',
17
-        'const' => 'color:#795da3',
18
-        'str' => 'color:#df5000',
19
-        'cchr' => 'color:#222',
20
-        'note' => 'color:#a71d5d',
21
-        'ref' => 'color:#a0a0a0',
22
-        'public' => 'color:#795da3',
23
-        'protected' => 'color:#795da3',
24
-        'private' => 'color:#795da3',
25
-        'meta' => 'color:#b729d9',
26
-        'key' => 'color:#df5000',
27
-        'index' => 'color:#a71d5d',
28
-    ];
9
+	/**
10
+	 * Colour definitions for output.
11
+	 *
12
+	 * @var array
13
+	 */
14
+	protected $styles = [
15
+		'default' => 'background-color:#fff; color:#222; line-height:1.2em; font-weight:normal; font:12px Monaco, Consolas, monospace; word-wrap: break-word; white-space: pre-wrap; position:relative; z-index:100000',
16
+		'num' => 'color:#a71d5d',
17
+		'const' => 'color:#795da3',
18
+		'str' => 'color:#df5000',
19
+		'cchr' => 'color:#222',
20
+		'note' => 'color:#a71d5d',
21
+		'ref' => 'color:#a0a0a0',
22
+		'public' => 'color:#795da3',
23
+		'protected' => 'color:#795da3',
24
+		'private' => 'color:#795da3',
25
+		'meta' => 'color:#b729d9',
26
+		'key' => 'color:#df5000',
27
+		'index' => 'color:#a71d5d',
28
+	];
29 29
 }
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -4,8 +4,7 @@
 block discarded – undo
4 4
 
5 5
 use Symfony\Component\VarDumper\Dumper\HtmlDumper as SymfonyHtmlDumper;
6 6
 
7
-class HtmlDumper extends SymfonyHtmlDumper
8
-{
7
+class HtmlDumper extends SymfonyHtmlDumper {
9 8
     /**
10 9
      * Colour definitions for output.
11 10
      *
Please login to merge, or discard this patch.
vendor/illuminate/support/Debug/Dumper.php 3 patches
Indentation   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -7,20 +7,20 @@
 block discarded – undo
7 7
 
8 8
 class Dumper
9 9
 {
10
-    /**
11
-     * Dump a value with elegance.
12
-     *
13
-     * @param  mixed  $value
14
-     * @return void
15
-     */
16
-    public function dump($value)
17
-    {
18
-        if (class_exists(CliDumper::class)) {
19
-            $dumper = 'cli' === PHP_SAPI ? new CliDumper : new HtmlDumper;
10
+	/**
11
+	 * Dump a value with elegance.
12
+	 *
13
+	 * @param  mixed  $value
14
+	 * @return void
15
+	 */
16
+	public function dump($value)
17
+	{
18
+		if (class_exists(CliDumper::class)) {
19
+			$dumper = 'cli' === PHP_SAPI ? new CliDumper : new HtmlDumper;
20 20
 
21
-            $dumper->dump((new VarCloner)->cloneVar($value));
22
-        } else {
23
-            var_dump($value);
24
-        }
25
-    }
21
+			$dumper->dump((new VarCloner)->cloneVar($value));
22
+		} else {
23
+			var_dump($value);
24
+		}
25
+	}
26 26
 }
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -13,14 +13,14 @@
 block discarded – undo
13 13
      * @param  mixed  $value
14 14
      * @return void
15 15
      */
16
-    public function dump($value)
16
+    public function dump( $value )
17 17
     {
18
-        if (class_exists(CliDumper::class)) {
18
+        if ( class_exists( CliDumper::class ) ) {
19 19
             $dumper = 'cli' === PHP_SAPI ? new CliDumper : new HtmlDumper;
20 20
 
21
-            $dumper->dump((new VarCloner)->cloneVar($value));
21
+            $dumper->dump( ( new VarCloner )->cloneVar( $value ) );
22 22
         } else {
23
-            var_dump($value);
23
+            var_dump( $value );
24 24
         }
25 25
     }
26 26
 }
Please login to merge, or discard this patch.
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -5,16 +5,14 @@
 block discarded – undo
5 5
 use Symfony\Component\VarDumper\Cloner\VarCloner;
6 6
 use Symfony\Component\VarDumper\Dumper\CliDumper;
7 7
 
8
-class Dumper
9
-{
8
+class Dumper {
10 9
     /**
11 10
      * Dump a value with elegance.
12 11
      *
13 12
      * @param  mixed  $value
14 13
      * @return void
15 14
      */
16
-    public function dump($value)
17
-    {
15
+    public function dump($value) {
18 16
         if (class_exists(CliDumper::class)) {
19 17
             $dumper = 'cli' === PHP_SAPI ? new CliDumper : new HtmlDumper;
20 18
 
Please login to merge, or discard this patch.
vendor/illuminate/contracts/Logging/Log.php 3 patches
Indentation   +82 added lines, -82 removed lines patch added patch discarded remove patch
@@ -4,95 +4,95 @@
 block discarded – undo
4 4
 
5 5
 interface Log
6 6
 {
7
-    /**
8
-     * Log an alert message to the logs.
9
-     *
10
-     * @param  string  $message
11
-     * @param  array  $context
12
-     * @return void
13
-     */
14
-    public function alert($message, array $context = []);
7
+	/**
8
+	 * Log an alert message to the logs.
9
+	 *
10
+	 * @param  string  $message
11
+	 * @param  array  $context
12
+	 * @return void
13
+	 */
14
+	public function alert($message, array $context = []);
15 15
 
16
-    /**
17
-     * Log a critical message to the logs.
18
-     *
19
-     * @param  string  $message
20
-     * @param  array  $context
21
-     * @return void
22
-     */
23
-    public function critical($message, array $context = []);
16
+	/**
17
+	 * Log a critical message to the logs.
18
+	 *
19
+	 * @param  string  $message
20
+	 * @param  array  $context
21
+	 * @return void
22
+	 */
23
+	public function critical($message, array $context = []);
24 24
 
25
-    /**
26
-     * Log an error message to the logs.
27
-     *
28
-     * @param  string  $message
29
-     * @param  array  $context
30
-     * @return void
31
-     */
32
-    public function error($message, array $context = []);
25
+	/**
26
+	 * Log an error message to the logs.
27
+	 *
28
+	 * @param  string  $message
29
+	 * @param  array  $context
30
+	 * @return void
31
+	 */
32
+	public function error($message, array $context = []);
33 33
 
34
-    /**
35
-     * Log a warning message to the logs.
36
-     *
37
-     * @param  string  $message
38
-     * @param  array  $context
39
-     * @return void
40
-     */
41
-    public function warning($message, array $context = []);
34
+	/**
35
+	 * Log a warning message to the logs.
36
+	 *
37
+	 * @param  string  $message
38
+	 * @param  array  $context
39
+	 * @return void
40
+	 */
41
+	public function warning($message, array $context = []);
42 42
 
43
-    /**
44
-     * Log a notice to the logs.
45
-     *
46
-     * @param  string  $message
47
-     * @param  array  $context
48
-     * @return void
49
-     */
50
-    public function notice($message, array $context = []);
43
+	/**
44
+	 * Log a notice to the logs.
45
+	 *
46
+	 * @param  string  $message
47
+	 * @param  array  $context
48
+	 * @return void
49
+	 */
50
+	public function notice($message, array $context = []);
51 51
 
52
-    /**
53
-     * Log an informational message to the logs.
54
-     *
55
-     * @param  string  $message
56
-     * @param  array  $context
57
-     * @return void
58
-     */
59
-    public function info($message, array $context = []);
52
+	/**
53
+	 * Log an informational message to the logs.
54
+	 *
55
+	 * @param  string  $message
56
+	 * @param  array  $context
57
+	 * @return void
58
+	 */
59
+	public function info($message, array $context = []);
60 60
 
61
-    /**
62
-     * Log a debug message to the logs.
63
-     *
64
-     * @param  string  $message
65
-     * @param  array  $context
66
-     * @return void
67
-     */
68
-    public function debug($message, array $context = []);
61
+	/**
62
+	 * Log a debug message to the logs.
63
+	 *
64
+	 * @param  string  $message
65
+	 * @param  array  $context
66
+	 * @return void
67
+	 */
68
+	public function debug($message, array $context = []);
69 69
 
70
-    /**
71
-     * Log a message to the logs.
72
-     *
73
-     * @param  string  $level
74
-     * @param  string  $message
75
-     * @param  array  $context
76
-     * @return void
77
-     */
78
-    public function log($level, $message, array $context = []);
70
+	/**
71
+	 * Log a message to the logs.
72
+	 *
73
+	 * @param  string  $level
74
+	 * @param  string  $message
75
+	 * @param  array  $context
76
+	 * @return void
77
+	 */
78
+	public function log($level, $message, array $context = []);
79 79
 
80
-    /**
81
-     * Register a file log handler.
82
-     *
83
-     * @param  string  $path
84
-     * @param  string  $level
85
-     * @return void
86
-     */
87
-    public function useFiles($path, $level = 'debug');
80
+	/**
81
+	 * Register a file log handler.
82
+	 *
83
+	 * @param  string  $path
84
+	 * @param  string  $level
85
+	 * @return void
86
+	 */
87
+	public function useFiles($path, $level = 'debug');
88 88
 
89
-    /**
90
-     * Register a daily file log handler.
91
-     *
92
-     * @param  string  $path
93
-     * @param  int     $days
94
-     * @param  string  $level
95
-     * @return void
96
-     */
97
-    public function useDailyFiles($path, $days = 0, $level = 'debug');
89
+	/**
90
+	 * Register a daily file log handler.
91
+	 *
92
+	 * @param  string  $path
93
+	 * @param  int     $days
94
+	 * @param  string  $level
95
+	 * @return void
96
+	 */
97
+	public function useDailyFiles($path, $days = 0, $level = 'debug');
98 98
 }
Please login to merge, or discard this patch.
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
      * @param  array  $context
12 12
      * @return void
13 13
      */
14
-    public function alert($message, array $context = []);
14
+    public function alert( $message, array $context = [ ] );
15 15
 
16 16
     /**
17 17
      * Log a critical message to the logs.
@@ -20,7 +20,7 @@  discard block
 block discarded – undo
20 20
      * @param  array  $context
21 21
      * @return void
22 22
      */
23
-    public function critical($message, array $context = []);
23
+    public function critical( $message, array $context = [ ] );
24 24
 
25 25
     /**
26 26
      * Log an error message to the logs.
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
      * @param  array  $context
30 30
      * @return void
31 31
      */
32
-    public function error($message, array $context = []);
32
+    public function error( $message, array $context = [ ] );
33 33
 
34 34
     /**
35 35
      * Log a warning message to the logs.
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
      * @param  array  $context
39 39
      * @return void
40 40
      */
41
-    public function warning($message, array $context = []);
41
+    public function warning( $message, array $context = [ ] );
42 42
 
43 43
     /**
44 44
      * Log a notice to the logs.
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
      * @param  array  $context
48 48
      * @return void
49 49
      */
50
-    public function notice($message, array $context = []);
50
+    public function notice( $message, array $context = [ ] );
51 51
 
52 52
     /**
53 53
      * Log an informational message to the logs.
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
      * @param  array  $context
57 57
      * @return void
58 58
      */
59
-    public function info($message, array $context = []);
59
+    public function info( $message, array $context = [ ] );
60 60
 
61 61
     /**
62 62
      * Log a debug message to the logs.
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
      * @param  array  $context
66 66
      * @return void
67 67
      */
68
-    public function debug($message, array $context = []);
68
+    public function debug( $message, array $context = [ ] );
69 69
 
70 70
     /**
71 71
      * Log a message to the logs.
@@ -75,7 +75,7 @@  discard block
 block discarded – undo
75 75
      * @param  array  $context
76 76
      * @return void
77 77
      */
78
-    public function log($level, $message, array $context = []);
78
+    public function log( $level, $message, array $context = [ ] );
79 79
 
80 80
     /**
81 81
      * Register a file log handler.
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
      * @param  string  $level
85 85
      * @return void
86 86
      */
87
-    public function useFiles($path, $level = 'debug');
87
+    public function useFiles( $path, $level = 'debug' );
88 88
 
89 89
     /**
90 90
      * Register a daily file log handler.
@@ -94,5 +94,5 @@  discard block
 block discarded – undo
94 94
      * @param  string  $level
95 95
      * @return void
96 96
      */
97
-    public function useDailyFiles($path, $days = 0, $level = 'debug');
97
+    public function useDailyFiles( $path, $days = 0, $level = 'debug' );
98 98
 }
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -2,8 +2,7 @@
 block discarded – undo
2 2
 
3 3
 namespace Illuminate\Contracts\Logging;
4 4
 
5
-interface Log
6
-{
5
+interface Log {
7 6
     /**
8 7
      * Log an alert message to the logs.
9 8
      *
Please login to merge, or discard this patch.
vendor/symfony/polyfill-mbstring/Mbstring.php 3 patches
Braces   +42 added lines, -84 removed lines patch added patch discarded remove patch
@@ -65,8 +65,7 @@  discard block
 block discarded – undo
65 65
  *
66 66
  * @internal
67 67
  */
68
-final class Mbstring
69
-{
68
+final class Mbstring {
70 69
     public const MB_CASE_FOLD = \PHP_INT_MAX;
71 70
 
72 71
     private const CASE_FOLD = [
@@ -78,8 +77,7 @@  discard block
 block discarded – undo
78 77
     private static $language = 'neutral';
79 78
     private static $internalEncoding = 'UTF-8';
80 79
 
81
-    public static function mb_convert_encoding($s, $toEncoding, $fromEncoding = null)
82
-    {
80
+    public static function mb_convert_encoding($s, $toEncoding, $fromEncoding = null) {
83 81
         if (\is_array($fromEncoding) || ($fromEncoding !== null && false !== strpos($fromEncoding, ','))) {
84 82
             $fromEncoding = self::mb_detect_encoding($s, $fromEncoding);
85 83
         } else {
@@ -116,8 +114,7 @@  discard block
 block discarded – undo
116 114
         return \iconv($fromEncoding, $toEncoding.'//IGNORE', $s);
117 115
     }
118 116
 
119
-    public static function mb_convert_variables($toEncoding, $fromEncoding, &...$vars)
120
-    {
117
+    public static function mb_convert_variables($toEncoding, $fromEncoding, &...$vars) {
121 118
         $ok = true;
122 119
         array_walk_recursive($vars, function (&$v) use (&$ok, $toEncoding, $fromEncoding) {
123 120
             if (false === $v = self::mb_convert_encoding($v, $toEncoding, $fromEncoding)) {
@@ -128,18 +125,15 @@  discard block
 block discarded – undo
128 125
         return $ok ? $fromEncoding : false;
129 126
     }
130 127
 
131
-    public static function mb_decode_mimeheader($s)
132
-    {
128
+    public static function mb_decode_mimeheader($s) {
133 129
         return \iconv_mime_decode($s, 2, self::$internalEncoding);
134 130
     }
135 131
 
136
-    public static function mb_encode_mimeheader($s, $charset = null, $transferEncoding = null, $linefeed = null, $indent = null)
137
-    {
132
+    public static function mb_encode_mimeheader($s, $charset = null, $transferEncoding = null, $linefeed = null, $indent = null) {
138 133
         trigger_error('mb_encode_mimeheader() is bugged. Please use iconv_mime_encode() instead', \E_USER_WARNING);
139 134
     }
140 135
 
141
-    public static function mb_decode_numericentity($s, $convmap, $encoding = null)
142
-    {
136
+    public static function mb_decode_numericentity($s, $convmap, $encoding = null) {
143 137
         if (null !== $s && !is_scalar($s) && !(\is_object($s) && method_exists($s, '__toString'))) {
144 138
             trigger_error('mb_decode_numericentity() expects parameter 1 to be string, '.\gettype($s).' given', \E_USER_WARNING);
145 139
 
@@ -198,8 +192,7 @@  discard block
 block discarded – undo
198 192
         return \iconv('UTF-8', $encoding.'//IGNORE', $s);
199 193
     }
200 194
 
201
-    public static function mb_encode_numericentity($s, $convmap, $encoding = null, $is_hex = false)
202
-    {
195
+    public static function mb_encode_numericentity($s, $convmap, $encoding = null, $is_hex = false) {
203 196
         if (null !== $s && !is_scalar($s) && !(\is_object($s) && method_exists($s, '__toString'))) {
204 197
             trigger_error('mb_encode_numericentity() expects parameter 1 to be string, '.\gettype($s).' given', \E_USER_WARNING);
205 198
 
@@ -268,8 +261,7 @@  discard block
 block discarded – undo
268 261
         return \iconv('UTF-8', $encoding.'//IGNORE', $result);
269 262
     }
270 263
 
271
-    public static function mb_convert_case($s, $mode, $encoding = null)
272
-    {
264
+    public static function mb_convert_case($s, $mode, $encoding = null) {
273 265
         $s = (string) $s;
274 266
         if ('' === $s) {
275 267
             return '';
@@ -346,8 +338,7 @@  discard block
 block discarded – undo
346 338
         return \iconv('UTF-8', $encoding.'//IGNORE', $s);
347 339
     }
348 340
 
349
-    public static function mb_internal_encoding($encoding = null)
350
-    {
341
+    public static function mb_internal_encoding($encoding = null) {
351 342
         if (null === $encoding) {
352 343
             return self::$internalEncoding;
353 344
         }
@@ -367,8 +358,7 @@  discard block
 block discarded – undo
367 358
         throw new \ValueError(sprintf('Argument #1 ($encoding) must be a valid encoding, "%s" given', $encoding));
368 359
     }
369 360
 
370
-    public static function mb_language($lang = null)
371
-    {
361
+    public static function mb_language($lang = null) {
372 362
         if (null === $lang) {
373 363
             return self::$language;
374 364
         }
@@ -388,13 +378,11 @@  discard block
 block discarded – undo
388 378
         throw new \ValueError(sprintf('Argument #1 ($language) must be a valid language, "%s" given', $lang));
389 379
     }
390 380
 
391
-    public static function mb_list_encodings()
392
-    {
381
+    public static function mb_list_encodings() {
393 382
         return ['UTF-8'];
394 383
     }
395 384
 
396
-    public static function mb_encoding_aliases($encoding)
397
-    {
385
+    public static function mb_encoding_aliases($encoding) {
398 386
         switch (strtoupper($encoding)) {
399 387
             case 'UTF8':
400 388
             case 'UTF-8':
@@ -404,8 +392,7 @@  discard block
 block discarded – undo
404 392
         return false;
405 393
     }
406 394
 
407
-    public static function mb_check_encoding($var = null, $encoding = null)
408
-    {
395
+    public static function mb_check_encoding($var = null, $encoding = null) {
409 396
         if (null === $encoding) {
410 397
             if (null === $var) {
411 398
                 return false;
@@ -416,8 +403,7 @@  discard block
 block discarded – undo
416 403
         return self::mb_detect_encoding($var, [$encoding]) || false !== @\iconv($encoding, $encoding, $var);
417 404
     }
418 405
 
419
-    public static function mb_detect_encoding($str, $encodingList = null, $strict = false)
420
-    {
406
+    public static function mb_detect_encoding($str, $encodingList = null, $strict = false) {
421 407
         if (null === $encodingList) {
422 408
             $encodingList = self::$encodingList;
423 409
         } else {
@@ -452,8 +438,7 @@  discard block
 block discarded – undo
452 438
         return false;
453 439
     }
454 440
 
455
-    public static function mb_detect_order($encodingList = null)
456
-    {
441
+    public static function mb_detect_order($encodingList = null) {
457 442
         if (null === $encodingList) {
458 443
             return self::$encodingList;
459 444
         }
@@ -481,8 +466,7 @@  discard block
 block discarded – undo
481 466
         return true;
482 467
     }
483 468
 
484
-    public static function mb_strlen($s, $encoding = null)
485
-    {
469
+    public static function mb_strlen($s, $encoding = null) {
486 470
         $encoding = self::getEncoding($encoding);
487 471
         if ('CP850' === $encoding || 'ASCII' === $encoding) {
488 472
             return \strlen($s);
@@ -491,8 +475,7 @@  discard block
 block discarded – undo
491 475
         return @\iconv_strlen($s, $encoding);
492 476
     }
493 477
 
494
-    public static function mb_strpos($haystack, $needle, $offset = 0, $encoding = null)
495
-    {
478
+    public static function mb_strpos($haystack, $needle, $offset = 0, $encoding = null) {
496 479
         $encoding = self::getEncoding($encoding);
497 480
         if ('CP850' === $encoding || 'ASCII' === $encoding) {
498 481
             return strpos($haystack, $needle, $offset);
@@ -512,8 +495,7 @@  discard block
 block discarded – undo
512 495
         return \iconv_strpos($haystack, $needle, $offset, $encoding);
513 496
     }
514 497
 
515
-    public static function mb_strrpos($haystack, $needle, $offset = 0, $encoding = null)
516
-    {
498
+    public static function mb_strrpos($haystack, $needle, $offset = 0, $encoding = null) {
517 499
         $encoding = self::getEncoding($encoding);
518 500
         if ('CP850' === $encoding || 'ASCII' === $encoding) {
519 501
             return strrpos($haystack, $needle, $offset);
@@ -539,8 +521,7 @@  discard block
 block discarded – undo
539 521
         return false !== $pos ? $offset + $pos : false;
540 522
     }
541 523
 
542
-    public static function mb_str_split($string, $split_length = 1, $encoding = null)
543
-    {
524
+    public static function mb_str_split($string, $split_length = 1, $encoding = null) {
544 525
         if (null !== $string && !is_scalar($string) && !(\is_object($string) && method_exists($string, '__toString'))) {
545 526
             trigger_error('mb_str_split() expects parameter 1 to be string, '.\gettype($string).' given', \E_USER_WARNING);
546 527
 
@@ -581,18 +562,15 @@  discard block
 block discarded – undo
581 562
         return $result;
582 563
     }
583 564
 
584
-    public static function mb_strtolower($s, $encoding = null)
585
-    {
565
+    public static function mb_strtolower($s, $encoding = null) {
586 566
         return self::mb_convert_case($s, \MB_CASE_LOWER, $encoding);
587 567
     }
588 568
 
589
-    public static function mb_strtoupper($s, $encoding = null)
590
-    {
569
+    public static function mb_strtoupper($s, $encoding = null) {
591 570
         return self::mb_convert_case($s, \MB_CASE_UPPER, $encoding);
592 571
     }
593 572
 
594
-    public static function mb_substitute_character($c = null)
595
-    {
573
+    public static function mb_substitute_character($c = null) {
596 574
         if (null === $c) {
597 575
             return 'none';
598 576
         }
@@ -609,8 +587,7 @@  discard block
 block discarded – undo
609 587
         throw new \ValueError('Argument #1 ($substitute_character) must be "none", "long", "entity" or a valid codepoint');
610 588
     }
611 589
 
612
-    public static function mb_substr($s, $start, $length = null, $encoding = null)
613
-    {
590
+    public static function mb_substr($s, $start, $length = null, $encoding = null) {
614 591
         $encoding = self::getEncoding($encoding);
615 592
         if ('CP850' === $encoding || 'ASCII' === $encoding) {
616 593
             return (string) substr($s, $start, null === $length ? 2147483647 : $length);
@@ -635,23 +612,20 @@  discard block
 block discarded – undo
635 612
         return (string) \iconv_substr($s, $start, $length, $encoding);
636 613
     }
637 614
 
638
-    public static function mb_stripos($haystack, $needle, $offset = 0, $encoding = null)
639
-    {
615
+    public static function mb_stripos($haystack, $needle, $offset = 0, $encoding = null) {
640 616
         $haystack = self::mb_convert_case($haystack, self::MB_CASE_FOLD, $encoding);
641 617
         $needle = self::mb_convert_case($needle, self::MB_CASE_FOLD, $encoding);
642 618
 
643 619
         return self::mb_strpos($haystack, $needle, $offset, $encoding);
644 620
     }
645 621
 
646
-    public static function mb_stristr($haystack, $needle, $part = false, $encoding = null)
647
-    {
622
+    public static function mb_stristr($haystack, $needle, $part = false, $encoding = null) {
648 623
         $pos = self::mb_stripos($haystack, $needle, 0, $encoding);
649 624
 
650 625
         return self::getSubpart($pos, $part, $haystack, $encoding);
651 626
     }
652 627
 
653
-    public static function mb_strrchr($haystack, $needle, $part = false, $encoding = null)
654
-    {
628
+    public static function mb_strrchr($haystack, $needle, $part = false, $encoding = null) {
655 629
         $encoding = self::getEncoding($encoding);
656 630
         if ('CP850' === $encoding || 'ASCII' === $encoding) {
657 631
             $pos = strrpos($haystack, $needle);
@@ -663,24 +637,21 @@  discard block
 block discarded – undo
663 637
         return self::getSubpart($pos, $part, $haystack, $encoding);
664 638
     }
665 639
 
666
-    public static function mb_strrichr($haystack, $needle, $part = false, $encoding = null)
667
-    {
640
+    public static function mb_strrichr($haystack, $needle, $part = false, $encoding = null) {
668 641
         $needle = self::mb_substr($needle, 0, 1, $encoding);
669 642
         $pos = self::mb_strripos($haystack, $needle, $encoding);
670 643
 
671 644
         return self::getSubpart($pos, $part, $haystack, $encoding);
672 645
     }
673 646
 
674
-    public static function mb_strripos($haystack, $needle, $offset = 0, $encoding = null)
675
-    {
647
+    public static function mb_strripos($haystack, $needle, $offset = 0, $encoding = null) {
676 648
         $haystack = self::mb_convert_case($haystack, self::MB_CASE_FOLD, $encoding);
677 649
         $needle = self::mb_convert_case($needle, self::MB_CASE_FOLD, $encoding);
678 650
 
679 651
         return self::mb_strrpos($haystack, $needle, $offset, $encoding);
680 652
     }
681 653
 
682
-    public static function mb_strstr($haystack, $needle, $part = false, $encoding = null)
683
-    {
654
+    public static function mb_strstr($haystack, $needle, $part = false, $encoding = null) {
684 655
         $pos = strpos($haystack, $needle);
685 656
         if (false === $pos) {
686 657
             return false;
@@ -692,8 +663,7 @@  discard block
 block discarded – undo
692 663
         return substr($haystack, $pos);
693 664
     }
694 665
 
695
-    public static function mb_get_info($type = 'all')
696
-    {
666
+    public static function mb_get_info($type = 'all') {
697 667
         $info = [
698 668
             'internal_encoding' => self::$internalEncoding,
699 669
             'http_output' => 'pass',
@@ -721,18 +691,15 @@  discard block
 block discarded – undo
721 691
         return false;
722 692
     }
723 693
 
724
-    public static function mb_http_input($type = '')
725
-    {
694
+    public static function mb_http_input($type = '') {
726 695
         return false;
727 696
     }
728 697
 
729
-    public static function mb_http_output($encoding = null)
730
-    {
698
+    public static function mb_http_output($encoding = null) {
731 699
         return null !== $encoding ? 'pass' === $encoding : 'pass';
732 700
     }
733 701
 
734
-    public static function mb_strwidth($s, $encoding = null)
735
-    {
702
+    public static function mb_strwidth($s, $encoding = null) {
736 703
         $encoding = self::getEncoding($encoding);
737 704
 
738 705
         if ('UTF-8' !== $encoding) {
@@ -744,18 +711,15 @@  discard block
 block discarded – undo
744 711
         return ($wide << 1) + \iconv_strlen($s, 'UTF-8');
745 712
     }
746 713
 
747
-    public static function mb_substr_count($haystack, $needle, $encoding = null)
748
-    {
714
+    public static function mb_substr_count($haystack, $needle, $encoding = null) {
749 715
         return substr_count($haystack, $needle);
750 716
     }
751 717
 
752
-    public static function mb_output_handler($contents, $status)
753
-    {
718
+    public static function mb_output_handler($contents, $status) {
754 719
         return $contents;
755 720
     }
756 721
 
757
-    public static function mb_chr($code, $encoding = null)
758
-    {
722
+    public static function mb_chr($code, $encoding = null) {
759 723
         if (0x80 > $code %= 0x200000) {
760 724
             $s = \chr($code);
761 725
         } elseif (0x800 > $code) {
@@ -773,8 +737,7 @@  discard block
 block discarded – undo
773 737
         return $s;
774 738
     }
775 739
 
776
-    public static function mb_ord($s, $encoding = null)
777
-    {
740
+    public static function mb_ord($s, $encoding = null) {
778 741
         if ('UTF-8' !== $encoding = self::getEncoding($encoding)) {
779 742
             $s = mb_convert_encoding($s, 'UTF-8', $encoding);
780 743
         }
@@ -797,8 +760,7 @@  discard block
 block discarded – undo
797 760
         return $code;
798 761
     }
799 762
 
800
-    private static function getSubpart($pos, $part, $haystack, $encoding)
801
-    {
763
+    private static function getSubpart($pos, $part, $haystack, $encoding) {
802 764
         if (false === $pos) {
803 765
             return false;
804 766
         }
@@ -809,8 +771,7 @@  discard block
 block discarded – undo
809 771
         return self::mb_substr($haystack, $pos, null, $encoding);
810 772
     }
811 773
 
812
-    private static function html_encoding_callback(array $m)
813
-    {
774
+    private static function html_encoding_callback(array $m) {
814 775
         $i = 1;
815 776
         $entities = '';
816 777
         $m = unpack('C*', htmlentities($m[0], \ENT_COMPAT, 'UTF-8'));
@@ -834,13 +795,11 @@  discard block
 block discarded – undo
834 795
         return $entities;
835 796
     }
836 797
 
837
-    private static function title_case(array $s)
838
-    {
798
+    private static function title_case(array $s) {
839 799
         return self::mb_convert_case($s[1], \MB_CASE_UPPER, 'UTF-8').self::mb_convert_case($s[2], \MB_CASE_LOWER, 'UTF-8');
840 800
     }
841 801
 
842
-    private static function getData($file)
843
-    {
802
+    private static function getData($file) {
844 803
         if (file_exists($file = __DIR__.'/Resources/unidata/'.$file.'.php')) {
845 804
             return require $file;
846 805
         }
@@ -848,8 +807,7 @@  discard block
 block discarded – undo
848 807
         return false;
849 808
     }
850 809
 
851
-    private static function getEncoding($encoding)
852
-    {
810
+    private static function getEncoding($encoding) {
853 811
         if (null === $encoding) {
854 812
             return self::$internalEncoding;
855 813
         }
Please login to merge, or discard this patch.
Indentation   +803 added lines, -803 removed lines patch added patch discarded remove patch
@@ -70,807 +70,807 @@
 block discarded – undo
70 70
  */
71 71
 final class Mbstring
72 72
 {
73
-    public const MB_CASE_FOLD = \PHP_INT_MAX;
74
-
75
-    private const CASE_FOLD = [
76
-        ['µ', 'ſ', "\xCD\x85", 'ς', "\xCF\x90", "\xCF\x91", "\xCF\x95", "\xCF\x96", "\xCF\xB0", "\xCF\xB1", "\xCF\xB5", "\xE1\xBA\x9B", "\xE1\xBE\xBE"],
77
-        ['μ', 's', 'ι',        'σ', 'β',        'θ',        'φ',        'π',        'κ',        'ρ',        'ε',        "\xE1\xB9\xA1", 'ι'],
78
-    ];
79
-
80
-    private static $encodingList = ['ASCII', 'UTF-8'];
81
-    private static $language = 'neutral';
82
-    private static $internalEncoding = 'UTF-8';
83
-
84
-    public static function mb_convert_encoding($s, $toEncoding, $fromEncoding = null)
85
-    {
86
-        if (\is_array($fromEncoding) || ($fromEncoding !== null && false !== strpos($fromEncoding, ','))) {
87
-            $fromEncoding = self::mb_detect_encoding($s, $fromEncoding);
88
-        } else {
89
-            $fromEncoding = self::getEncoding($fromEncoding);
90
-        }
91
-
92
-        $toEncoding = self::getEncoding($toEncoding);
93
-
94
-        if ('BASE64' === $fromEncoding) {
95
-            $s = base64_decode($s);
96
-            $fromEncoding = $toEncoding;
97
-        }
98
-
99
-        if ('BASE64' === $toEncoding) {
100
-            return base64_encode($s);
101
-        }
102
-
103
-        if ('HTML-ENTITIES' === $toEncoding || 'HTML' === $toEncoding) {
104
-            if ('HTML-ENTITIES' === $fromEncoding || 'HTML' === $fromEncoding) {
105
-                $fromEncoding = 'Windows-1252';
106
-            }
107
-            if ('UTF-8' !== $fromEncoding) {
108
-                $s = \iconv($fromEncoding, 'UTF-8//IGNORE', $s);
109
-            }
110
-
111
-            return preg_replace_callback('/[\x80-\xFF]+/', [__CLASS__, 'html_encoding_callback'], $s);
112
-        }
113
-
114
-        if ('HTML-ENTITIES' === $fromEncoding) {
115
-            $s = html_entity_decode($s, \ENT_COMPAT, 'UTF-8');
116
-            $fromEncoding = 'UTF-8';
117
-        }
118
-
119
-        return \iconv($fromEncoding, $toEncoding.'//IGNORE', $s);
120
-    }
121
-
122
-    public static function mb_convert_variables($toEncoding, $fromEncoding, &...$vars)
123
-    {
124
-        $ok = true;
125
-        array_walk_recursive($vars, function (&$v) use (&$ok, $toEncoding, $fromEncoding) {
126
-            if (false === $v = self::mb_convert_encoding($v, $toEncoding, $fromEncoding)) {
127
-                $ok = false;
128
-            }
129
-        });
130
-
131
-        return $ok ? $fromEncoding : false;
132
-    }
133
-
134
-    public static function mb_decode_mimeheader($s)
135
-    {
136
-        return \iconv_mime_decode($s, 2, self::$internalEncoding);
137
-    }
138
-
139
-    public static function mb_encode_mimeheader($s, $charset = null, $transferEncoding = null, $linefeed = null, $indent = null)
140
-    {
141
-        trigger_error('mb_encode_mimeheader() is bugged. Please use iconv_mime_encode() instead', \E_USER_WARNING);
142
-    }
143
-
144
-    public static function mb_decode_numericentity($s, $convmap, $encoding = null)
145
-    {
146
-        if (null !== $s && !is_scalar($s) && !(\is_object($s) && method_exists($s, '__toString'))) {
147
-            trigger_error('mb_decode_numericentity() expects parameter 1 to be string, '.\gettype($s).' given', \E_USER_WARNING);
148
-
149
-            return null;
150
-        }
151
-
152
-        if (!\is_array($convmap) || (80000 > \PHP_VERSION_ID && !$convmap)) {
153
-            return false;
154
-        }
155
-
156
-        if (null !== $encoding && !is_scalar($encoding)) {
157
-            trigger_error('mb_decode_numericentity() expects parameter 3 to be string, '.\gettype($s).' given', \E_USER_WARNING);
158
-
159
-            return '';  // Instead of null (cf. mb_encode_numericentity).
160
-        }
161
-
162
-        $s = (string) $s;
163
-        if ('' === $s) {
164
-            return '';
165
-        }
166
-
167
-        $encoding = self::getEncoding($encoding);
168
-
169
-        if ('UTF-8' === $encoding) {
170
-            $encoding = null;
171
-            if (!preg_match('//u', $s)) {
172
-                $s = @\iconv('UTF-8', 'UTF-8//IGNORE', $s);
173
-            }
174
-        } else {
175
-            $s = \iconv($encoding, 'UTF-8//IGNORE', $s);
176
-        }
177
-
178
-        $cnt = floor(\count($convmap) / 4) * 4;
179
-
180
-        for ($i = 0; $i < $cnt; $i += 4) {
181
-            // collector_decode_htmlnumericentity ignores $convmap[$i + 3]
182
-            $convmap[$i] += $convmap[$i + 2];
183
-            $convmap[$i + 1] += $convmap[$i + 2];
184
-        }
185
-
186
-        $s = preg_replace_callback('/&#(?:0*([0-9]+)|x0*([0-9a-fA-F]+))(?!&);?/', function (array $m) use ($cnt, $convmap) {
187
-            $c = isset($m[2]) ? (int) hexdec($m[2]) : $m[1];
188
-            for ($i = 0; $i < $cnt; $i += 4) {
189
-                if ($c >= $convmap[$i] && $c <= $convmap[$i + 1]) {
190
-                    return self::mb_chr($c - $convmap[$i + 2]);
191
-                }
192
-            }
193
-
194
-            return $m[0];
195
-        }, $s);
196
-
197
-        if (null === $encoding) {
198
-            return $s;
199
-        }
200
-
201
-        return \iconv('UTF-8', $encoding.'//IGNORE', $s);
202
-    }
203
-
204
-    public static function mb_encode_numericentity($s, $convmap, $encoding = null, $is_hex = false)
205
-    {
206
-        if (null !== $s && !is_scalar($s) && !(\is_object($s) && method_exists($s, '__toString'))) {
207
-            trigger_error('mb_encode_numericentity() expects parameter 1 to be string, '.\gettype($s).' given', \E_USER_WARNING);
208
-
209
-            return null;
210
-        }
211
-
212
-        if (!\is_array($convmap) || (80000 > \PHP_VERSION_ID && !$convmap)) {
213
-            return false;
214
-        }
215
-
216
-        if (null !== $encoding && !is_scalar($encoding)) {
217
-            trigger_error('mb_encode_numericentity() expects parameter 3 to be string, '.\gettype($s).' given', \E_USER_WARNING);
218
-
219
-            return null;  // Instead of '' (cf. mb_decode_numericentity).
220
-        }
221
-
222
-        if (null !== $is_hex && !is_scalar($is_hex)) {
223
-            trigger_error('mb_encode_numericentity() expects parameter 4 to be boolean, '.\gettype($s).' given', \E_USER_WARNING);
224
-
225
-            return null;
226
-        }
227
-
228
-        $s = (string) $s;
229
-        if ('' === $s) {
230
-            return '';
231
-        }
232
-
233
-        $encoding = self::getEncoding($encoding);
234
-
235
-        if ('UTF-8' === $encoding) {
236
-            $encoding = null;
237
-            if (!preg_match('//u', $s)) {
238
-                $s = @\iconv('UTF-8', 'UTF-8//IGNORE', $s);
239
-            }
240
-        } else {
241
-            $s = \iconv($encoding, 'UTF-8//IGNORE', $s);
242
-        }
243
-
244
-        static $ulenMask = ["\xC0" => 2, "\xD0" => 2, "\xE0" => 3, "\xF0" => 4];
245
-
246
-        $cnt = floor(\count($convmap) / 4) * 4;
247
-        $i = 0;
248
-        $len = \strlen($s);
249
-        $result = '';
250
-
251
-        while ($i < $len) {
252
-            $ulen = $s[$i] < "\x80" ? 1 : $ulenMask[$s[$i] & "\xF0"];
253
-            $uchr = substr($s, $i, $ulen);
254
-            $i += $ulen;
255
-            $c = self::mb_ord($uchr);
256
-
257
-            for ($j = 0; $j < $cnt; $j += 4) {
258
-                if ($c >= $convmap[$j] && $c <= $convmap[$j + 1]) {
259
-                    $cOffset = ($c + $convmap[$j + 2]) & $convmap[$j + 3];
260
-                    $result .= $is_hex ? sprintf('&#x%X;', $cOffset) : '&#'.$cOffset.';';
261
-                    continue 2;
262
-                }
263
-            }
264
-            $result .= $uchr;
265
-        }
266
-
267
-        if (null === $encoding) {
268
-            return $result;
269
-        }
270
-
271
-        return \iconv('UTF-8', $encoding.'//IGNORE', $result);
272
-    }
273
-
274
-    public static function mb_convert_case($s, $mode, $encoding = null)
275
-    {
276
-        $s = (string) $s;
277
-        if ('' === $s) {
278
-            return '';
279
-        }
280
-
281
-        $encoding = self::getEncoding($encoding);
282
-
283
-        if ('UTF-8' === $encoding) {
284
-            $encoding = null;
285
-            if (!preg_match('//u', $s)) {
286
-                $s = @\iconv('UTF-8', 'UTF-8//IGNORE', $s);
287
-            }
288
-        } else {
289
-            $s = \iconv($encoding, 'UTF-8//IGNORE', $s);
290
-        }
291
-
292
-        if (\MB_CASE_TITLE == $mode) {
293
-            static $titleRegexp = null;
294
-            if (null === $titleRegexp) {
295
-                $titleRegexp = self::getData('titleCaseRegexp');
296
-            }
297
-            $s = preg_replace_callback($titleRegexp, [__CLASS__, 'title_case'], $s);
298
-        } else {
299
-            if (\MB_CASE_UPPER == $mode) {
300
-                static $upper = null;
301
-                if (null === $upper) {
302
-                    $upper = self::getData('upperCase');
303
-                }
304
-                $map = $upper;
305
-            } else {
306
-                if (self::MB_CASE_FOLD === $mode) {
307
-                    $s = str_replace(self::CASE_FOLD[0], self::CASE_FOLD[1], $s);
308
-                }
309
-
310
-                static $lower = null;
311
-                if (null === $lower) {
312
-                    $lower = self::getData('lowerCase');
313
-                }
314
-                $map = $lower;
315
-            }
316
-
317
-            static $ulenMask = ["\xC0" => 2, "\xD0" => 2, "\xE0" => 3, "\xF0" => 4];
318
-
319
-            $i = 0;
320
-            $len = \strlen($s);
321
-
322
-            while ($i < $len) {
323
-                $ulen = $s[$i] < "\x80" ? 1 : $ulenMask[$s[$i] & "\xF0"];
324
-                $uchr = substr($s, $i, $ulen);
325
-                $i += $ulen;
326
-
327
-                if (isset($map[$uchr])) {
328
-                    $uchr = $map[$uchr];
329
-                    $nlen = \strlen($uchr);
330
-
331
-                    if ($nlen == $ulen) {
332
-                        $nlen = $i;
333
-                        do {
334
-                            $s[--$nlen] = $uchr[--$ulen];
335
-                        } while ($ulen);
336
-                    } else {
337
-                        $s = substr_replace($s, $uchr, $i - $ulen, $ulen);
338
-                        $len += $nlen - $ulen;
339
-                        $i += $nlen - $ulen;
340
-                    }
341
-                }
342
-            }
343
-        }
344
-
345
-        if (null === $encoding) {
346
-            return $s;
347
-        }
348
-
349
-        return \iconv('UTF-8', $encoding.'//IGNORE', $s);
350
-    }
351
-
352
-    public static function mb_internal_encoding($encoding = null)
353
-    {
354
-        if (null === $encoding) {
355
-            return self::$internalEncoding;
356
-        }
357
-
358
-        $normalizedEncoding = self::getEncoding($encoding);
359
-
360
-        if ('UTF-8' === $normalizedEncoding || false !== @\iconv($normalizedEncoding, $normalizedEncoding, ' ')) {
361
-            self::$internalEncoding = $normalizedEncoding;
362
-
363
-            return true;
364
-        }
365
-
366
-        if (80000 > \PHP_VERSION_ID) {
367
-            return false;
368
-        }
369
-
370
-        throw new \ValueError(sprintf('Argument #1 ($encoding) must be a valid encoding, "%s" given', $encoding));
371
-    }
372
-
373
-    public static function mb_language($lang = null)
374
-    {
375
-        if (null === $lang) {
376
-            return self::$language;
377
-        }
378
-
379
-        switch ($normalizedLang = strtolower($lang)) {
380
-            case 'uni':
381
-            case 'neutral':
382
-                self::$language = $normalizedLang;
383
-
384
-                return true;
385
-        }
386
-
387
-        if (80000 > \PHP_VERSION_ID) {
388
-            return false;
389
-        }
390
-
391
-        throw new \ValueError(sprintf('Argument #1 ($language) must be a valid language, "%s" given', $lang));
392
-    }
393
-
394
-    public static function mb_list_encodings()
395
-    {
396
-        return ['UTF-8'];
397
-    }
398
-
399
-    public static function mb_encoding_aliases($encoding)
400
-    {
401
-        switch (strtoupper($encoding)) {
402
-            case 'UTF8':
403
-            case 'UTF-8':
404
-                return ['utf8'];
405
-        }
406
-
407
-        return false;
408
-    }
409
-
410
-    public static function mb_check_encoding($var = null, $encoding = null)
411
-    {
412
-        if (null === $encoding) {
413
-            if (null === $var) {
414
-                return false;
415
-            }
416
-            $encoding = self::$internalEncoding;
417
-        }
418
-
419
-        return self::mb_detect_encoding($var, [$encoding]) || false !== @\iconv($encoding, $encoding, $var);
420
-    }
421
-
422
-    public static function mb_detect_encoding($str, $encodingList = null, $strict = false)
423
-    {
424
-        if (null === $encodingList) {
425
-            $encodingList = self::$encodingList;
426
-        } else {
427
-            if (!\is_array($encodingList)) {
428
-                $encodingList = array_map('trim', explode(',', $encodingList));
429
-            }
430
-            $encodingList = array_map('strtoupper', $encodingList);
431
-        }
432
-
433
-        foreach ($encodingList as $enc) {
434
-            switch ($enc) {
435
-                case 'ASCII':
436
-                    if (!preg_match('/[\x80-\xFF]/', $str)) {
437
-                        return $enc;
438
-                    }
439
-                    break;
440
-
441
-                case 'UTF8':
442
-                case 'UTF-8':
443
-                    if (preg_match('//u', $str)) {
444
-                        return 'UTF-8';
445
-                    }
446
-                    break;
447
-
448
-                default:
449
-                    if (0 === strncmp($enc, 'ISO-8859-', 9)) {
450
-                        return $enc;
451
-                    }
452
-            }
453
-        }
454
-
455
-        return false;
456
-    }
457
-
458
-    public static function mb_detect_order($encodingList = null)
459
-    {
460
-        if (null === $encodingList) {
461
-            return self::$encodingList;
462
-        }
463
-
464
-        if (!\is_array($encodingList)) {
465
-            $encodingList = array_map('trim', explode(',', $encodingList));
466
-        }
467
-        $encodingList = array_map('strtoupper', $encodingList);
468
-
469
-        foreach ($encodingList as $enc) {
470
-            switch ($enc) {
471
-                default:
472
-                    if (strncmp($enc, 'ISO-8859-', 9)) {
473
-                        return false;
474
-                    }
475
-                    // no break
476
-                case 'ASCII':
477
-                case 'UTF8':
478
-                case 'UTF-8':
479
-            }
480
-        }
481
-
482
-        self::$encodingList = $encodingList;
483
-
484
-        return true;
485
-    }
486
-
487
-    public static function mb_strlen($s, $encoding = null)
488
-    {
489
-        $encoding = self::getEncoding($encoding);
490
-        if ('CP850' === $encoding || 'ASCII' === $encoding) {
491
-            return \strlen($s);
492
-        }
493
-
494
-        return @\iconv_strlen($s, $encoding);
495
-    }
496
-
497
-    public static function mb_strpos($haystack, $needle, $offset = 0, $encoding = null)
498
-    {
499
-        $encoding = self::getEncoding($encoding);
500
-        if ('CP850' === $encoding || 'ASCII' === $encoding) {
501
-            return strpos($haystack, $needle, $offset);
502
-        }
503
-
504
-        $needle = (string) $needle;
505
-        if ('' === $needle) {
506
-            if (80000 > \PHP_VERSION_ID) {
507
-                trigger_error(__METHOD__.': Empty delimiter', \E_USER_WARNING);
508
-
509
-                return false;
510
-            }
511
-
512
-            return 0;
513
-        }
514
-
515
-        return \iconv_strpos($haystack, $needle, $offset, $encoding);
516
-    }
517
-
518
-    public static function mb_strrpos($haystack, $needle, $offset = 0, $encoding = null)
519
-    {
520
-        $encoding = self::getEncoding($encoding);
521
-        if ('CP850' === $encoding || 'ASCII' === $encoding) {
522
-            return strrpos($haystack, $needle, $offset);
523
-        }
524
-
525
-        if ($offset != (int) $offset) {
526
-            $offset = 0;
527
-        } elseif ($offset = (int) $offset) {
528
-            if ($offset < 0) {
529
-                if (0 > $offset += self::mb_strlen($needle)) {
530
-                    $haystack = self::mb_substr($haystack, 0, $offset, $encoding);
531
-                }
532
-                $offset = 0;
533
-            } else {
534
-                $haystack = self::mb_substr($haystack, $offset, 2147483647, $encoding);
535
-            }
536
-        }
537
-
538
-        $pos = '' !== $needle || 80000 > \PHP_VERSION_ID
539
-            ? \iconv_strrpos($haystack, $needle, $encoding)
540
-            : self::mb_strlen($haystack, $encoding);
541
-
542
-        return false !== $pos ? $offset + $pos : false;
543
-    }
544
-
545
-    public static function mb_str_split($string, $split_length = 1, $encoding = null)
546
-    {
547
-        if (null !== $string && !is_scalar($string) && !(\is_object($string) && method_exists($string, '__toString'))) {
548
-            trigger_error('mb_str_split() expects parameter 1 to be string, '.\gettype($string).' given', \E_USER_WARNING);
549
-
550
-            return null;
551
-        }
552
-
553
-        if (1 > $split_length = (int) $split_length) {
554
-            if (80000 > \PHP_VERSION_ID) {
555
-                trigger_error('The length of each segment must be greater than zero', \E_USER_WARNING);
556
-                return false;
557
-            }
558
-
559
-            throw new \ValueError('Argument #2 ($length) must be greater than 0');
560
-        }
561
-
562
-        if (null === $encoding) {
563
-            $encoding = mb_internal_encoding();
564
-        }
565
-
566
-        if ('UTF-8' === $encoding = self::getEncoding($encoding)) {
567
-            $rx = '/(';
568
-            while (65535 < $split_length) {
569
-                $rx .= '.{65535}';
570
-                $split_length -= 65535;
571
-            }
572
-            $rx .= '.{'.$split_length.'})/us';
573
-
574
-            return preg_split($rx, $string, -1, \PREG_SPLIT_DELIM_CAPTURE | \PREG_SPLIT_NO_EMPTY);
575
-        }
576
-
577
-        $result = [];
578
-        $length = mb_strlen($string, $encoding);
579
-
580
-        for ($i = 0; $i < $length; $i += $split_length) {
581
-            $result[] = mb_substr($string, $i, $split_length, $encoding);
582
-        }
583
-
584
-        return $result;
585
-    }
586
-
587
-    public static function mb_strtolower($s, $encoding = null)
588
-    {
589
-        return self::mb_convert_case($s, \MB_CASE_LOWER, $encoding);
590
-    }
591
-
592
-    public static function mb_strtoupper($s, $encoding = null)
593
-    {
594
-        return self::mb_convert_case($s, \MB_CASE_UPPER, $encoding);
595
-    }
596
-
597
-    public static function mb_substitute_character($c = null)
598
-    {
599
-        if (null === $c) {
600
-            return 'none';
601
-        }
602
-        if (0 === strcasecmp($c, 'none')) {
603
-            return true;
604
-        }
605
-        if (80000 > \PHP_VERSION_ID) {
606
-            return false;
607
-        }
608
-        if (\is_int($c) || 'long' === $c || 'entity' === $c) {
609
-            return false;
610
-        }
611
-
612
-        throw new \ValueError('Argument #1 ($substitute_character) must be "none", "long", "entity" or a valid codepoint');
613
-    }
614
-
615
-    public static function mb_substr($s, $start, $length = null, $encoding = null)
616
-    {
617
-        $encoding = self::getEncoding($encoding);
618
-        if ('CP850' === $encoding || 'ASCII' === $encoding) {
619
-            return (string) substr($s, $start, null === $length ? 2147483647 : $length);
620
-        }
621
-
622
-        if ($start < 0) {
623
-            $start = \iconv_strlen($s, $encoding) + $start;
624
-            if ($start < 0) {
625
-                $start = 0;
626
-            }
627
-        }
628
-
629
-        if (null === $length) {
630
-            $length = 2147483647;
631
-        } elseif ($length < 0) {
632
-            $length = \iconv_strlen($s, $encoding) + $length - $start;
633
-            if ($length < 0) {
634
-                return '';
635
-            }
636
-        }
637
-
638
-        return (string) \iconv_substr($s, $start, $length, $encoding);
639
-    }
640
-
641
-    public static function mb_stripos($haystack, $needle, $offset = 0, $encoding = null)
642
-    {
643
-        $haystack = self::mb_convert_case($haystack, self::MB_CASE_FOLD, $encoding);
644
-        $needle = self::mb_convert_case($needle, self::MB_CASE_FOLD, $encoding);
645
-
646
-        return self::mb_strpos($haystack, $needle, $offset, $encoding);
647
-    }
648
-
649
-    public static function mb_stristr($haystack, $needle, $part = false, $encoding = null)
650
-    {
651
-        $pos = self::mb_stripos($haystack, $needle, 0, $encoding);
652
-
653
-        return self::getSubpart($pos, $part, $haystack, $encoding);
654
-    }
655
-
656
-    public static function mb_strrchr($haystack, $needle, $part = false, $encoding = null)
657
-    {
658
-        $encoding = self::getEncoding($encoding);
659
-        if ('CP850' === $encoding || 'ASCII' === $encoding) {
660
-            $pos = strrpos($haystack, $needle);
661
-        } else {
662
-            $needle = self::mb_substr($needle, 0, 1, $encoding);
663
-            $pos = \iconv_strrpos($haystack, $needle, $encoding);
664
-        }
665
-
666
-        return self::getSubpart($pos, $part, $haystack, $encoding);
667
-    }
668
-
669
-    public static function mb_strrichr($haystack, $needle, $part = false, $encoding = null)
670
-    {
671
-        $needle = self::mb_substr($needle, 0, 1, $encoding);
672
-        $pos = self::mb_strripos($haystack, $needle, $encoding);
673
-
674
-        return self::getSubpart($pos, $part, $haystack, $encoding);
675
-    }
676
-
677
-    public static function mb_strripos($haystack, $needle, $offset = 0, $encoding = null)
678
-    {
679
-        $haystack = self::mb_convert_case($haystack, self::MB_CASE_FOLD, $encoding);
680
-        $needle = self::mb_convert_case($needle, self::MB_CASE_FOLD, $encoding);
681
-
682
-        return self::mb_strrpos($haystack, $needle, $offset, $encoding);
683
-    }
684
-
685
-    public static function mb_strstr($haystack, $needle, $part = false, $encoding = null)
686
-    {
687
-        $pos = strpos($haystack, $needle);
688
-        if (false === $pos) {
689
-            return false;
690
-        }
691
-        if ($part) {
692
-            return substr($haystack, 0, $pos);
693
-        }
694
-
695
-        return substr($haystack, $pos);
696
-    }
697
-
698
-    public static function mb_get_info($type = 'all')
699
-    {
700
-        $info = [
701
-            'internal_encoding' => self::$internalEncoding,
702
-            'http_output' => 'pass',
703
-            'http_output_conv_mimetypes' => '^(text/|application/xhtml\+xml)',
704
-            'func_overload' => 0,
705
-            'func_overload_list' => 'no overload',
706
-            'mail_charset' => 'UTF-8',
707
-            'mail_header_encoding' => 'BASE64',
708
-            'mail_body_encoding' => 'BASE64',
709
-            'illegal_chars' => 0,
710
-            'encoding_translation' => 'Off',
711
-            'language' => self::$language,
712
-            'detect_order' => self::$encodingList,
713
-            'substitute_character' => 'none',
714
-            'strict_detection' => 'Off',
715
-        ];
716
-
717
-        if ('all' === $type) {
718
-            return $info;
719
-        }
720
-        if (isset($info[$type])) {
721
-            return $info[$type];
722
-        }
723
-
724
-        return false;
725
-    }
726
-
727
-    public static function mb_http_input($type = '')
728
-    {
729
-        return false;
730
-    }
731
-
732
-    public static function mb_http_output($encoding = null)
733
-    {
734
-        return null !== $encoding ? 'pass' === $encoding : 'pass';
735
-    }
736
-
737
-    public static function mb_strwidth($s, $encoding = null)
738
-    {
739
-        $encoding = self::getEncoding($encoding);
740
-
741
-        if ('UTF-8' !== $encoding) {
742
-            $s = \iconv($encoding, 'UTF-8//IGNORE', $s);
743
-        }
744
-
745
-        $s = preg_replace('/[\x{1100}-\x{115F}\x{2329}\x{232A}\x{2E80}-\x{303E}\x{3040}-\x{A4CF}\x{AC00}-\x{D7A3}\x{F900}-\x{FAFF}\x{FE10}-\x{FE19}\x{FE30}-\x{FE6F}\x{FF00}-\x{FF60}\x{FFE0}-\x{FFE6}\x{20000}-\x{2FFFD}\x{30000}-\x{3FFFD}]/u', '', $s, -1, $wide);
746
-
747
-        return ($wide << 1) + \iconv_strlen($s, 'UTF-8');
748
-    }
749
-
750
-    public static function mb_substr_count($haystack, $needle, $encoding = null)
751
-    {
752
-        return substr_count($haystack, $needle);
753
-    }
754
-
755
-    public static function mb_output_handler($contents, $status)
756
-    {
757
-        return $contents;
758
-    }
759
-
760
-    public static function mb_chr($code, $encoding = null)
761
-    {
762
-        if (0x80 > $code %= 0x200000) {
763
-            $s = \chr($code);
764
-        } elseif (0x800 > $code) {
765
-            $s = \chr(0xC0 | $code >> 6).\chr(0x80 | $code & 0x3F);
766
-        } elseif (0x10000 > $code) {
767
-            $s = \chr(0xE0 | $code >> 12).\chr(0x80 | $code >> 6 & 0x3F).\chr(0x80 | $code & 0x3F);
768
-        } else {
769
-            $s = \chr(0xF0 | $code >> 18).\chr(0x80 | $code >> 12 & 0x3F).\chr(0x80 | $code >> 6 & 0x3F).\chr(0x80 | $code & 0x3F);
770
-        }
771
-
772
-        if ('UTF-8' !== $encoding = self::getEncoding($encoding)) {
773
-            $s = mb_convert_encoding($s, $encoding, 'UTF-8');
774
-        }
775
-
776
-        return $s;
777
-    }
778
-
779
-    public static function mb_ord($s, $encoding = null)
780
-    {
781
-        if ('UTF-8' !== $encoding = self::getEncoding($encoding)) {
782
-            $s = mb_convert_encoding($s, 'UTF-8', $encoding);
783
-        }
784
-
785
-        if (1 === \strlen($s)) {
786
-            return \ord($s);
787
-        }
788
-
789
-        $code = ($s = unpack('C*', substr($s, 0, 4))) ? $s[1] : 0;
790
-        if (0xF0 <= $code) {
791
-            return (($code - 0xF0) << 18) + (($s[2] - 0x80) << 12) + (($s[3] - 0x80) << 6) + $s[4] - 0x80;
792
-        }
793
-        if (0xE0 <= $code) {
794
-            return (($code - 0xE0) << 12) + (($s[2] - 0x80) << 6) + $s[3] - 0x80;
795
-        }
796
-        if (0xC0 <= $code) {
797
-            return (($code - 0xC0) << 6) + $s[2] - 0x80;
798
-        }
799
-
800
-        return $code;
801
-    }
802
-
803
-    private static function getSubpart($pos, $part, $haystack, $encoding)
804
-    {
805
-        if (false === $pos) {
806
-            return false;
807
-        }
808
-        if ($part) {
809
-            return self::mb_substr($haystack, 0, $pos, $encoding);
810
-        }
811
-
812
-        return self::mb_substr($haystack, $pos, null, $encoding);
813
-    }
814
-
815
-    private static function html_encoding_callback(array $m)
816
-    {
817
-        $i = 1;
818
-        $entities = '';
819
-        $m = unpack('C*', htmlentities($m[0], \ENT_COMPAT, 'UTF-8'));
820
-
821
-        while (isset($m[$i])) {
822
-            if (0x80 > $m[$i]) {
823
-                $entities .= \chr($m[$i++]);
824
-                continue;
825
-            }
826
-            if (0xF0 <= $m[$i]) {
827
-                $c = (($m[$i++] - 0xF0) << 18) + (($m[$i++] - 0x80) << 12) + (($m[$i++] - 0x80) << 6) + $m[$i++] - 0x80;
828
-            } elseif (0xE0 <= $m[$i]) {
829
-                $c = (($m[$i++] - 0xE0) << 12) + (($m[$i++] - 0x80) << 6) + $m[$i++] - 0x80;
830
-            } else {
831
-                $c = (($m[$i++] - 0xC0) << 6) + $m[$i++] - 0x80;
832
-            }
833
-
834
-            $entities .= '&#'.$c.';';
835
-        }
836
-
837
-        return $entities;
838
-    }
839
-
840
-    private static function title_case(array $s)
841
-    {
842
-        return self::mb_convert_case($s[1], \MB_CASE_UPPER, 'UTF-8').self::mb_convert_case($s[2], \MB_CASE_LOWER, 'UTF-8');
843
-    }
844
-
845
-    private static function getData($file)
846
-    {
847
-        if (file_exists($file = __DIR__.'/Resources/unidata/'.$file.'.php')) {
848
-            return require $file;
849
-        }
850
-
851
-        return false;
852
-    }
853
-
854
-    private static function getEncoding($encoding)
855
-    {
856
-        if (null === $encoding) {
857
-            return self::$internalEncoding;
858
-        }
859
-
860
-        if ('UTF-8' === $encoding) {
861
-            return 'UTF-8';
862
-        }
863
-
864
-        $encoding = strtoupper($encoding);
865
-
866
-        if ('8BIT' === $encoding || 'BINARY' === $encoding) {
867
-            return 'CP850';
868
-        }
869
-
870
-        if ('UTF8' === $encoding) {
871
-            return 'UTF-8';
872
-        }
873
-
874
-        return $encoding;
875
-    }
73
+	public const MB_CASE_FOLD = \PHP_INT_MAX;
74
+
75
+	private const CASE_FOLD = [
76
+		['µ', 'ſ', "\xCD\x85", 'ς', "\xCF\x90", "\xCF\x91", "\xCF\x95", "\xCF\x96", "\xCF\xB0", "\xCF\xB1", "\xCF\xB5", "\xE1\xBA\x9B", "\xE1\xBE\xBE"],
77
+		['μ', 's', 'ι',        'σ', 'β',        'θ',        'φ',        'π',        'κ',        'ρ',        'ε',        "\xE1\xB9\xA1", 'ι'],
78
+	];
79
+
80
+	private static $encodingList = ['ASCII', 'UTF-8'];
81
+	private static $language = 'neutral';
82
+	private static $internalEncoding = 'UTF-8';
83
+
84
+	public static function mb_convert_encoding($s, $toEncoding, $fromEncoding = null)
85
+	{
86
+		if (\is_array($fromEncoding) || ($fromEncoding !== null && false !== strpos($fromEncoding, ','))) {
87
+			$fromEncoding = self::mb_detect_encoding($s, $fromEncoding);
88
+		} else {
89
+			$fromEncoding = self::getEncoding($fromEncoding);
90
+		}
91
+
92
+		$toEncoding = self::getEncoding($toEncoding);
93
+
94
+		if ('BASE64' === $fromEncoding) {
95
+			$s = base64_decode($s);
96
+			$fromEncoding = $toEncoding;
97
+		}
98
+
99
+		if ('BASE64' === $toEncoding) {
100
+			return base64_encode($s);
101
+		}
102
+
103
+		if ('HTML-ENTITIES' === $toEncoding || 'HTML' === $toEncoding) {
104
+			if ('HTML-ENTITIES' === $fromEncoding || 'HTML' === $fromEncoding) {
105
+				$fromEncoding = 'Windows-1252';
106
+			}
107
+			if ('UTF-8' !== $fromEncoding) {
108
+				$s = \iconv($fromEncoding, 'UTF-8//IGNORE', $s);
109
+			}
110
+
111
+			return preg_replace_callback('/[\x80-\xFF]+/', [__CLASS__, 'html_encoding_callback'], $s);
112
+		}
113
+
114
+		if ('HTML-ENTITIES' === $fromEncoding) {
115
+			$s = html_entity_decode($s, \ENT_COMPAT, 'UTF-8');
116
+			$fromEncoding = 'UTF-8';
117
+		}
118
+
119
+		return \iconv($fromEncoding, $toEncoding.'//IGNORE', $s);
120
+	}
121
+
122
+	public static function mb_convert_variables($toEncoding, $fromEncoding, &...$vars)
123
+	{
124
+		$ok = true;
125
+		array_walk_recursive($vars, function (&$v) use (&$ok, $toEncoding, $fromEncoding) {
126
+			if (false === $v = self::mb_convert_encoding($v, $toEncoding, $fromEncoding)) {
127
+				$ok = false;
128
+			}
129
+		});
130
+
131
+		return $ok ? $fromEncoding : false;
132
+	}
133
+
134
+	public static function mb_decode_mimeheader($s)
135
+	{
136
+		return \iconv_mime_decode($s, 2, self::$internalEncoding);
137
+	}
138
+
139
+	public static function mb_encode_mimeheader($s, $charset = null, $transferEncoding = null, $linefeed = null, $indent = null)
140
+	{
141
+		trigger_error('mb_encode_mimeheader() is bugged. Please use iconv_mime_encode() instead', \E_USER_WARNING);
142
+	}
143
+
144
+	public static function mb_decode_numericentity($s, $convmap, $encoding = null)
145
+	{
146
+		if (null !== $s && !is_scalar($s) && !(\is_object($s) && method_exists($s, '__toString'))) {
147
+			trigger_error('mb_decode_numericentity() expects parameter 1 to be string, '.\gettype($s).' given', \E_USER_WARNING);
148
+
149
+			return null;
150
+		}
151
+
152
+		if (!\is_array($convmap) || (80000 > \PHP_VERSION_ID && !$convmap)) {
153
+			return false;
154
+		}
155
+
156
+		if (null !== $encoding && !is_scalar($encoding)) {
157
+			trigger_error('mb_decode_numericentity() expects parameter 3 to be string, '.\gettype($s).' given', \E_USER_WARNING);
158
+
159
+			return '';  // Instead of null (cf. mb_encode_numericentity).
160
+		}
161
+
162
+		$s = (string) $s;
163
+		if ('' === $s) {
164
+			return '';
165
+		}
166
+
167
+		$encoding = self::getEncoding($encoding);
168
+
169
+		if ('UTF-8' === $encoding) {
170
+			$encoding = null;
171
+			if (!preg_match('//u', $s)) {
172
+				$s = @\iconv('UTF-8', 'UTF-8//IGNORE', $s);
173
+			}
174
+		} else {
175
+			$s = \iconv($encoding, 'UTF-8//IGNORE', $s);
176
+		}
177
+
178
+		$cnt = floor(\count($convmap) / 4) * 4;
179
+
180
+		for ($i = 0; $i < $cnt; $i += 4) {
181
+			// collector_decode_htmlnumericentity ignores $convmap[$i + 3]
182
+			$convmap[$i] += $convmap[$i + 2];
183
+			$convmap[$i + 1] += $convmap[$i + 2];
184
+		}
185
+
186
+		$s = preg_replace_callback('/&#(?:0*([0-9]+)|x0*([0-9a-fA-F]+))(?!&);?/', function (array $m) use ($cnt, $convmap) {
187
+			$c = isset($m[2]) ? (int) hexdec($m[2]) : $m[1];
188
+			for ($i = 0; $i < $cnt; $i += 4) {
189
+				if ($c >= $convmap[$i] && $c <= $convmap[$i + 1]) {
190
+					return self::mb_chr($c - $convmap[$i + 2]);
191
+				}
192
+			}
193
+
194
+			return $m[0];
195
+		}, $s);
196
+
197
+		if (null === $encoding) {
198
+			return $s;
199
+		}
200
+
201
+		return \iconv('UTF-8', $encoding.'//IGNORE', $s);
202
+	}
203
+
204
+	public static function mb_encode_numericentity($s, $convmap, $encoding = null, $is_hex = false)
205
+	{
206
+		if (null !== $s && !is_scalar($s) && !(\is_object($s) && method_exists($s, '__toString'))) {
207
+			trigger_error('mb_encode_numericentity() expects parameter 1 to be string, '.\gettype($s).' given', \E_USER_WARNING);
208
+
209
+			return null;
210
+		}
211
+
212
+		if (!\is_array($convmap) || (80000 > \PHP_VERSION_ID && !$convmap)) {
213
+			return false;
214
+		}
215
+
216
+		if (null !== $encoding && !is_scalar($encoding)) {
217
+			trigger_error('mb_encode_numericentity() expects parameter 3 to be string, '.\gettype($s).' given', \E_USER_WARNING);
218
+
219
+			return null;  // Instead of '' (cf. mb_decode_numericentity).
220
+		}
221
+
222
+		if (null !== $is_hex && !is_scalar($is_hex)) {
223
+			trigger_error('mb_encode_numericentity() expects parameter 4 to be boolean, '.\gettype($s).' given', \E_USER_WARNING);
224
+
225
+			return null;
226
+		}
227
+
228
+		$s = (string) $s;
229
+		if ('' === $s) {
230
+			return '';
231
+		}
232
+
233
+		$encoding = self::getEncoding($encoding);
234
+
235
+		if ('UTF-8' === $encoding) {
236
+			$encoding = null;
237
+			if (!preg_match('//u', $s)) {
238
+				$s = @\iconv('UTF-8', 'UTF-8//IGNORE', $s);
239
+			}
240
+		} else {
241
+			$s = \iconv($encoding, 'UTF-8//IGNORE', $s);
242
+		}
243
+
244
+		static $ulenMask = ["\xC0" => 2, "\xD0" => 2, "\xE0" => 3, "\xF0" => 4];
245
+
246
+		$cnt = floor(\count($convmap) / 4) * 4;
247
+		$i = 0;
248
+		$len = \strlen($s);
249
+		$result = '';
250
+
251
+		while ($i < $len) {
252
+			$ulen = $s[$i] < "\x80" ? 1 : $ulenMask[$s[$i] & "\xF0"];
253
+			$uchr = substr($s, $i, $ulen);
254
+			$i += $ulen;
255
+			$c = self::mb_ord($uchr);
256
+
257
+			for ($j = 0; $j < $cnt; $j += 4) {
258
+				if ($c >= $convmap[$j] && $c <= $convmap[$j + 1]) {
259
+					$cOffset = ($c + $convmap[$j + 2]) & $convmap[$j + 3];
260
+					$result .= $is_hex ? sprintf('&#x%X;', $cOffset) : '&#'.$cOffset.';';
261
+					continue 2;
262
+				}
263
+			}
264
+			$result .= $uchr;
265
+		}
266
+
267
+		if (null === $encoding) {
268
+			return $result;
269
+		}
270
+
271
+		return \iconv('UTF-8', $encoding.'//IGNORE', $result);
272
+	}
273
+
274
+	public static function mb_convert_case($s, $mode, $encoding = null)
275
+	{
276
+		$s = (string) $s;
277
+		if ('' === $s) {
278
+			return '';
279
+		}
280
+
281
+		$encoding = self::getEncoding($encoding);
282
+
283
+		if ('UTF-8' === $encoding) {
284
+			$encoding = null;
285
+			if (!preg_match('//u', $s)) {
286
+				$s = @\iconv('UTF-8', 'UTF-8//IGNORE', $s);
287
+			}
288
+		} else {
289
+			$s = \iconv($encoding, 'UTF-8//IGNORE', $s);
290
+		}
291
+
292
+		if (\MB_CASE_TITLE == $mode) {
293
+			static $titleRegexp = null;
294
+			if (null === $titleRegexp) {
295
+				$titleRegexp = self::getData('titleCaseRegexp');
296
+			}
297
+			$s = preg_replace_callback($titleRegexp, [__CLASS__, 'title_case'], $s);
298
+		} else {
299
+			if (\MB_CASE_UPPER == $mode) {
300
+				static $upper = null;
301
+				if (null === $upper) {
302
+					$upper = self::getData('upperCase');
303
+				}
304
+				$map = $upper;
305
+			} else {
306
+				if (self::MB_CASE_FOLD === $mode) {
307
+					$s = str_replace(self::CASE_FOLD[0], self::CASE_FOLD[1], $s);
308
+				}
309
+
310
+				static $lower = null;
311
+				if (null === $lower) {
312
+					$lower = self::getData('lowerCase');
313
+				}
314
+				$map = $lower;
315
+			}
316
+
317
+			static $ulenMask = ["\xC0" => 2, "\xD0" => 2, "\xE0" => 3, "\xF0" => 4];
318
+
319
+			$i = 0;
320
+			$len = \strlen($s);
321
+
322
+			while ($i < $len) {
323
+				$ulen = $s[$i] < "\x80" ? 1 : $ulenMask[$s[$i] & "\xF0"];
324
+				$uchr = substr($s, $i, $ulen);
325
+				$i += $ulen;
326
+
327
+				if (isset($map[$uchr])) {
328
+					$uchr = $map[$uchr];
329
+					$nlen = \strlen($uchr);
330
+
331
+					if ($nlen == $ulen) {
332
+						$nlen = $i;
333
+						do {
334
+							$s[--$nlen] = $uchr[--$ulen];
335
+						} while ($ulen);
336
+					} else {
337
+						$s = substr_replace($s, $uchr, $i - $ulen, $ulen);
338
+						$len += $nlen - $ulen;
339
+						$i += $nlen - $ulen;
340
+					}
341
+				}
342
+			}
343
+		}
344
+
345
+		if (null === $encoding) {
346
+			return $s;
347
+		}
348
+
349
+		return \iconv('UTF-8', $encoding.'//IGNORE', $s);
350
+	}
351
+
352
+	public static function mb_internal_encoding($encoding = null)
353
+	{
354
+		if (null === $encoding) {
355
+			return self::$internalEncoding;
356
+		}
357
+
358
+		$normalizedEncoding = self::getEncoding($encoding);
359
+
360
+		if ('UTF-8' === $normalizedEncoding || false !== @\iconv($normalizedEncoding, $normalizedEncoding, ' ')) {
361
+			self::$internalEncoding = $normalizedEncoding;
362
+
363
+			return true;
364
+		}
365
+
366
+		if (80000 > \PHP_VERSION_ID) {
367
+			return false;
368
+		}
369
+
370
+		throw new \ValueError(sprintf('Argument #1 ($encoding) must be a valid encoding, "%s" given', $encoding));
371
+	}
372
+
373
+	public static function mb_language($lang = null)
374
+	{
375
+		if (null === $lang) {
376
+			return self::$language;
377
+		}
378
+
379
+		switch ($normalizedLang = strtolower($lang)) {
380
+			case 'uni':
381
+			case 'neutral':
382
+				self::$language = $normalizedLang;
383
+
384
+				return true;
385
+		}
386
+
387
+		if (80000 > \PHP_VERSION_ID) {
388
+			return false;
389
+		}
390
+
391
+		throw new \ValueError(sprintf('Argument #1 ($language) must be a valid language, "%s" given', $lang));
392
+	}
393
+
394
+	public static function mb_list_encodings()
395
+	{
396
+		return ['UTF-8'];
397
+	}
398
+
399
+	public static function mb_encoding_aliases($encoding)
400
+	{
401
+		switch (strtoupper($encoding)) {
402
+			case 'UTF8':
403
+			case 'UTF-8':
404
+				return ['utf8'];
405
+		}
406
+
407
+		return false;
408
+	}
409
+
410
+	public static function mb_check_encoding($var = null, $encoding = null)
411
+	{
412
+		if (null === $encoding) {
413
+			if (null === $var) {
414
+				return false;
415
+			}
416
+			$encoding = self::$internalEncoding;
417
+		}
418
+
419
+		return self::mb_detect_encoding($var, [$encoding]) || false !== @\iconv($encoding, $encoding, $var);
420
+	}
421
+
422
+	public static function mb_detect_encoding($str, $encodingList = null, $strict = false)
423
+	{
424
+		if (null === $encodingList) {
425
+			$encodingList = self::$encodingList;
426
+		} else {
427
+			if (!\is_array($encodingList)) {
428
+				$encodingList = array_map('trim', explode(',', $encodingList));
429
+			}
430
+			$encodingList = array_map('strtoupper', $encodingList);
431
+		}
432
+
433
+		foreach ($encodingList as $enc) {
434
+			switch ($enc) {
435
+				case 'ASCII':
436
+					if (!preg_match('/[\x80-\xFF]/', $str)) {
437
+						return $enc;
438
+					}
439
+					break;
440
+
441
+				case 'UTF8':
442
+				case 'UTF-8':
443
+					if (preg_match('//u', $str)) {
444
+						return 'UTF-8';
445
+					}
446
+					break;
447
+
448
+				default:
449
+					if (0 === strncmp($enc, 'ISO-8859-', 9)) {
450
+						return $enc;
451
+					}
452
+			}
453
+		}
454
+
455
+		return false;
456
+	}
457
+
458
+	public static function mb_detect_order($encodingList = null)
459
+	{
460
+		if (null === $encodingList) {
461
+			return self::$encodingList;
462
+		}
463
+
464
+		if (!\is_array($encodingList)) {
465
+			$encodingList = array_map('trim', explode(',', $encodingList));
466
+		}
467
+		$encodingList = array_map('strtoupper', $encodingList);
468
+
469
+		foreach ($encodingList as $enc) {
470
+			switch ($enc) {
471
+				default:
472
+					if (strncmp($enc, 'ISO-8859-', 9)) {
473
+						return false;
474
+					}
475
+					// no break
476
+				case 'ASCII':
477
+				case 'UTF8':
478
+				case 'UTF-8':
479
+			}
480
+		}
481
+
482
+		self::$encodingList = $encodingList;
483
+
484
+		return true;
485
+	}
486
+
487
+	public static function mb_strlen($s, $encoding = null)
488
+	{
489
+		$encoding = self::getEncoding($encoding);
490
+		if ('CP850' === $encoding || 'ASCII' === $encoding) {
491
+			return \strlen($s);
492
+		}
493
+
494
+		return @\iconv_strlen($s, $encoding);
495
+	}
496
+
497
+	public static function mb_strpos($haystack, $needle, $offset = 0, $encoding = null)
498
+	{
499
+		$encoding = self::getEncoding($encoding);
500
+		if ('CP850' === $encoding || 'ASCII' === $encoding) {
501
+			return strpos($haystack, $needle, $offset);
502
+		}
503
+
504
+		$needle = (string) $needle;
505
+		if ('' === $needle) {
506
+			if (80000 > \PHP_VERSION_ID) {
507
+				trigger_error(__METHOD__.': Empty delimiter', \E_USER_WARNING);
508
+
509
+				return false;
510
+			}
511
+
512
+			return 0;
513
+		}
514
+
515
+		return \iconv_strpos($haystack, $needle, $offset, $encoding);
516
+	}
517
+
518
+	public static function mb_strrpos($haystack, $needle, $offset = 0, $encoding = null)
519
+	{
520
+		$encoding = self::getEncoding($encoding);
521
+		if ('CP850' === $encoding || 'ASCII' === $encoding) {
522
+			return strrpos($haystack, $needle, $offset);
523
+		}
524
+
525
+		if ($offset != (int) $offset) {
526
+			$offset = 0;
527
+		} elseif ($offset = (int) $offset) {
528
+			if ($offset < 0) {
529
+				if (0 > $offset += self::mb_strlen($needle)) {
530
+					$haystack = self::mb_substr($haystack, 0, $offset, $encoding);
531
+				}
532
+				$offset = 0;
533
+			} else {
534
+				$haystack = self::mb_substr($haystack, $offset, 2147483647, $encoding);
535
+			}
536
+		}
537
+
538
+		$pos = '' !== $needle || 80000 > \PHP_VERSION_ID
539
+			? \iconv_strrpos($haystack, $needle, $encoding)
540
+			: self::mb_strlen($haystack, $encoding);
541
+
542
+		return false !== $pos ? $offset + $pos : false;
543
+	}
544
+
545
+	public static function mb_str_split($string, $split_length = 1, $encoding = null)
546
+	{
547
+		if (null !== $string && !is_scalar($string) && !(\is_object($string) && method_exists($string, '__toString'))) {
548
+			trigger_error('mb_str_split() expects parameter 1 to be string, '.\gettype($string).' given', \E_USER_WARNING);
549
+
550
+			return null;
551
+		}
552
+
553
+		if (1 > $split_length = (int) $split_length) {
554
+			if (80000 > \PHP_VERSION_ID) {
555
+				trigger_error('The length of each segment must be greater than zero', \E_USER_WARNING);
556
+				return false;
557
+			}
558
+
559
+			throw new \ValueError('Argument #2 ($length) must be greater than 0');
560
+		}
561
+
562
+		if (null === $encoding) {
563
+			$encoding = mb_internal_encoding();
564
+		}
565
+
566
+		if ('UTF-8' === $encoding = self::getEncoding($encoding)) {
567
+			$rx = '/(';
568
+			while (65535 < $split_length) {
569
+				$rx .= '.{65535}';
570
+				$split_length -= 65535;
571
+			}
572
+			$rx .= '.{'.$split_length.'})/us';
573
+
574
+			return preg_split($rx, $string, -1, \PREG_SPLIT_DELIM_CAPTURE | \PREG_SPLIT_NO_EMPTY);
575
+		}
576
+
577
+		$result = [];
578
+		$length = mb_strlen($string, $encoding);
579
+
580
+		for ($i = 0; $i < $length; $i += $split_length) {
581
+			$result[] = mb_substr($string, $i, $split_length, $encoding);
582
+		}
583
+
584
+		return $result;
585
+	}
586
+
587
+	public static function mb_strtolower($s, $encoding = null)
588
+	{
589
+		return self::mb_convert_case($s, \MB_CASE_LOWER, $encoding);
590
+	}
591
+
592
+	public static function mb_strtoupper($s, $encoding = null)
593
+	{
594
+		return self::mb_convert_case($s, \MB_CASE_UPPER, $encoding);
595
+	}
596
+
597
+	public static function mb_substitute_character($c = null)
598
+	{
599
+		if (null === $c) {
600
+			return 'none';
601
+		}
602
+		if (0 === strcasecmp($c, 'none')) {
603
+			return true;
604
+		}
605
+		if (80000 > \PHP_VERSION_ID) {
606
+			return false;
607
+		}
608
+		if (\is_int($c) || 'long' === $c || 'entity' === $c) {
609
+			return false;
610
+		}
611
+
612
+		throw new \ValueError('Argument #1 ($substitute_character) must be "none", "long", "entity" or a valid codepoint');
613
+	}
614
+
615
+	public static function mb_substr($s, $start, $length = null, $encoding = null)
616
+	{
617
+		$encoding = self::getEncoding($encoding);
618
+		if ('CP850' === $encoding || 'ASCII' === $encoding) {
619
+			return (string) substr($s, $start, null === $length ? 2147483647 : $length);
620
+		}
621
+
622
+		if ($start < 0) {
623
+			$start = \iconv_strlen($s, $encoding) + $start;
624
+			if ($start < 0) {
625
+				$start = 0;
626
+			}
627
+		}
628
+
629
+		if (null === $length) {
630
+			$length = 2147483647;
631
+		} elseif ($length < 0) {
632
+			$length = \iconv_strlen($s, $encoding) + $length - $start;
633
+			if ($length < 0) {
634
+				return '';
635
+			}
636
+		}
637
+
638
+		return (string) \iconv_substr($s, $start, $length, $encoding);
639
+	}
640
+
641
+	public static function mb_stripos($haystack, $needle, $offset = 0, $encoding = null)
642
+	{
643
+		$haystack = self::mb_convert_case($haystack, self::MB_CASE_FOLD, $encoding);
644
+		$needle = self::mb_convert_case($needle, self::MB_CASE_FOLD, $encoding);
645
+
646
+		return self::mb_strpos($haystack, $needle, $offset, $encoding);
647
+	}
648
+
649
+	public static function mb_stristr($haystack, $needle, $part = false, $encoding = null)
650
+	{
651
+		$pos = self::mb_stripos($haystack, $needle, 0, $encoding);
652
+
653
+		return self::getSubpart($pos, $part, $haystack, $encoding);
654
+	}
655
+
656
+	public static function mb_strrchr($haystack, $needle, $part = false, $encoding = null)
657
+	{
658
+		$encoding = self::getEncoding($encoding);
659
+		if ('CP850' === $encoding || 'ASCII' === $encoding) {
660
+			$pos = strrpos($haystack, $needle);
661
+		} else {
662
+			$needle = self::mb_substr($needle, 0, 1, $encoding);
663
+			$pos = \iconv_strrpos($haystack, $needle, $encoding);
664
+		}
665
+
666
+		return self::getSubpart($pos, $part, $haystack, $encoding);
667
+	}
668
+
669
+	public static function mb_strrichr($haystack, $needle, $part = false, $encoding = null)
670
+	{
671
+		$needle = self::mb_substr($needle, 0, 1, $encoding);
672
+		$pos = self::mb_strripos($haystack, $needle, $encoding);
673
+
674
+		return self::getSubpart($pos, $part, $haystack, $encoding);
675
+	}
676
+
677
+	public static function mb_strripos($haystack, $needle, $offset = 0, $encoding = null)
678
+	{
679
+		$haystack = self::mb_convert_case($haystack, self::MB_CASE_FOLD, $encoding);
680
+		$needle = self::mb_convert_case($needle, self::MB_CASE_FOLD, $encoding);
681
+
682
+		return self::mb_strrpos($haystack, $needle, $offset, $encoding);
683
+	}
684
+
685
+	public static function mb_strstr($haystack, $needle, $part = false, $encoding = null)
686
+	{
687
+		$pos = strpos($haystack, $needle);
688
+		if (false === $pos) {
689
+			return false;
690
+		}
691
+		if ($part) {
692
+			return substr($haystack, 0, $pos);
693
+		}
694
+
695
+		return substr($haystack, $pos);
696
+	}
697
+
698
+	public static function mb_get_info($type = 'all')
699
+	{
700
+		$info = [
701
+			'internal_encoding' => self::$internalEncoding,
702
+			'http_output' => 'pass',
703
+			'http_output_conv_mimetypes' => '^(text/|application/xhtml\+xml)',
704
+			'func_overload' => 0,
705
+			'func_overload_list' => 'no overload',
706
+			'mail_charset' => 'UTF-8',
707
+			'mail_header_encoding' => 'BASE64',
708
+			'mail_body_encoding' => 'BASE64',
709
+			'illegal_chars' => 0,
710
+			'encoding_translation' => 'Off',
711
+			'language' => self::$language,
712
+			'detect_order' => self::$encodingList,
713
+			'substitute_character' => 'none',
714
+			'strict_detection' => 'Off',
715
+		];
716
+
717
+		if ('all' === $type) {
718
+			return $info;
719
+		}
720
+		if (isset($info[$type])) {
721
+			return $info[$type];
722
+		}
723
+
724
+		return false;
725
+	}
726
+
727
+	public static function mb_http_input($type = '')
728
+	{
729
+		return false;
730
+	}
731
+
732
+	public static function mb_http_output($encoding = null)
733
+	{
734
+		return null !== $encoding ? 'pass' === $encoding : 'pass';
735
+	}
736
+
737
+	public static function mb_strwidth($s, $encoding = null)
738
+	{
739
+		$encoding = self::getEncoding($encoding);
740
+
741
+		if ('UTF-8' !== $encoding) {
742
+			$s = \iconv($encoding, 'UTF-8//IGNORE', $s);
743
+		}
744
+
745
+		$s = preg_replace('/[\x{1100}-\x{115F}\x{2329}\x{232A}\x{2E80}-\x{303E}\x{3040}-\x{A4CF}\x{AC00}-\x{D7A3}\x{F900}-\x{FAFF}\x{FE10}-\x{FE19}\x{FE30}-\x{FE6F}\x{FF00}-\x{FF60}\x{FFE0}-\x{FFE6}\x{20000}-\x{2FFFD}\x{30000}-\x{3FFFD}]/u', '', $s, -1, $wide);
746
+
747
+		return ($wide << 1) + \iconv_strlen($s, 'UTF-8');
748
+	}
749
+
750
+	public static function mb_substr_count($haystack, $needle, $encoding = null)
751
+	{
752
+		return substr_count($haystack, $needle);
753
+	}
754
+
755
+	public static function mb_output_handler($contents, $status)
756
+	{
757
+		return $contents;
758
+	}
759
+
760
+	public static function mb_chr($code, $encoding = null)
761
+	{
762
+		if (0x80 > $code %= 0x200000) {
763
+			$s = \chr($code);
764
+		} elseif (0x800 > $code) {
765
+			$s = \chr(0xC0 | $code >> 6).\chr(0x80 | $code & 0x3F);
766
+		} elseif (0x10000 > $code) {
767
+			$s = \chr(0xE0 | $code >> 12).\chr(0x80 | $code >> 6 & 0x3F).\chr(0x80 | $code & 0x3F);
768
+		} else {
769
+			$s = \chr(0xF0 | $code >> 18).\chr(0x80 | $code >> 12 & 0x3F).\chr(0x80 | $code >> 6 & 0x3F).\chr(0x80 | $code & 0x3F);
770
+		}
771
+
772
+		if ('UTF-8' !== $encoding = self::getEncoding($encoding)) {
773
+			$s = mb_convert_encoding($s, $encoding, 'UTF-8');
774
+		}
775
+
776
+		return $s;
777
+	}
778
+
779
+	public static function mb_ord($s, $encoding = null)
780
+	{
781
+		if ('UTF-8' !== $encoding = self::getEncoding($encoding)) {
782
+			$s = mb_convert_encoding($s, 'UTF-8', $encoding);
783
+		}
784
+
785
+		if (1 === \strlen($s)) {
786
+			return \ord($s);
787
+		}
788
+
789
+		$code = ($s = unpack('C*', substr($s, 0, 4))) ? $s[1] : 0;
790
+		if (0xF0 <= $code) {
791
+			return (($code - 0xF0) << 18) + (($s[2] - 0x80) << 12) + (($s[3] - 0x80) << 6) + $s[4] - 0x80;
792
+		}
793
+		if (0xE0 <= $code) {
794
+			return (($code - 0xE0) << 12) + (($s[2] - 0x80) << 6) + $s[3] - 0x80;
795
+		}
796
+		if (0xC0 <= $code) {
797
+			return (($code - 0xC0) << 6) + $s[2] - 0x80;
798
+		}
799
+
800
+		return $code;
801
+	}
802
+
803
+	private static function getSubpart($pos, $part, $haystack, $encoding)
804
+	{
805
+		if (false === $pos) {
806
+			return false;
807
+		}
808
+		if ($part) {
809
+			return self::mb_substr($haystack, 0, $pos, $encoding);
810
+		}
811
+
812
+		return self::mb_substr($haystack, $pos, null, $encoding);
813
+	}
814
+
815
+	private static function html_encoding_callback(array $m)
816
+	{
817
+		$i = 1;
818
+		$entities = '';
819
+		$m = unpack('C*', htmlentities($m[0], \ENT_COMPAT, 'UTF-8'));
820
+
821
+		while (isset($m[$i])) {
822
+			if (0x80 > $m[$i]) {
823
+				$entities .= \chr($m[$i++]);
824
+				continue;
825
+			}
826
+			if (0xF0 <= $m[$i]) {
827
+				$c = (($m[$i++] - 0xF0) << 18) + (($m[$i++] - 0x80) << 12) + (($m[$i++] - 0x80) << 6) + $m[$i++] - 0x80;
828
+			} elseif (0xE0 <= $m[$i]) {
829
+				$c = (($m[$i++] - 0xE0) << 12) + (($m[$i++] - 0x80) << 6) + $m[$i++] - 0x80;
830
+			} else {
831
+				$c = (($m[$i++] - 0xC0) << 6) + $m[$i++] - 0x80;
832
+			}
833
+
834
+			$entities .= '&#'.$c.';';
835
+		}
836
+
837
+		return $entities;
838
+	}
839
+
840
+	private static function title_case(array $s)
841
+	{
842
+		return self::mb_convert_case($s[1], \MB_CASE_UPPER, 'UTF-8').self::mb_convert_case($s[2], \MB_CASE_LOWER, 'UTF-8');
843
+	}
844
+
845
+	private static function getData($file)
846
+	{
847
+		if (file_exists($file = __DIR__.'/Resources/unidata/'.$file.'.php')) {
848
+			return require $file;
849
+		}
850
+
851
+		return false;
852
+	}
853
+
854
+	private static function getEncoding($encoding)
855
+	{
856
+		if (null === $encoding) {
857
+			return self::$internalEncoding;
858
+		}
859
+
860
+		if ('UTF-8' === $encoding) {
861
+			return 'UTF-8';
862
+		}
863
+
864
+		$encoding = strtoupper($encoding);
865
+
866
+		if ('8BIT' === $encoding || 'BINARY' === $encoding) {
867
+			return 'CP850';
868
+		}
869
+
870
+		if ('UTF8' === $encoding) {
871
+			return 'UTF-8';
872
+		}
873
+
874
+		return $encoding;
875
+	}
876 876
 }
Please login to merge, or discard this patch.
Spacing   +308 added lines, -308 removed lines patch added patch discarded remove patch
@@ -73,57 +73,57 @@  discard block
 block discarded – undo
73 73
     public const MB_CASE_FOLD = \PHP_INT_MAX;
74 74
 
75 75
     private const CASE_FOLD = [
76
-        ['µ', 'ſ', "\xCD\x85", 'ς', "\xCF\x90", "\xCF\x91", "\xCF\x95", "\xCF\x96", "\xCF\xB0", "\xCF\xB1", "\xCF\xB5", "\xE1\xBA\x9B", "\xE1\xBE\xBE"],
77
-        ['μ', 's', 'ι',        'σ', 'β',        'θ',        'φ',        'π',        'κ',        'ρ',        'ε',        "\xE1\xB9\xA1", 'ι'],
76
+        [ 'µ', 'ſ', "\xCD\x85", 'ς', "\xCF\x90", "\xCF\x91", "\xCF\x95", "\xCF\x96", "\xCF\xB0", "\xCF\xB1", "\xCF\xB5", "\xE1\xBA\x9B", "\xE1\xBE\xBE" ],
77
+        [ 'μ', 's', 'ι', 'σ', 'β', 'θ', 'φ', 'π', 'κ', 'ρ', 'ε', "\xE1\xB9\xA1", 'ι' ],
78 78
     ];
79 79
 
80
-    private static $encodingList = ['ASCII', 'UTF-8'];
80
+    private static $encodingList = [ 'ASCII', 'UTF-8' ];
81 81
     private static $language = 'neutral';
82 82
     private static $internalEncoding = 'UTF-8';
83 83
 
84
-    public static function mb_convert_encoding($s, $toEncoding, $fromEncoding = null)
84
+    public static function mb_convert_encoding( $s, $toEncoding, $fromEncoding = null )
85 85
     {
86
-        if (\is_array($fromEncoding) || ($fromEncoding !== null && false !== strpos($fromEncoding, ','))) {
87
-            $fromEncoding = self::mb_detect_encoding($s, $fromEncoding);
86
+        if ( \is_array( $fromEncoding ) || ( $fromEncoding !== null && false !== strpos( $fromEncoding, ',' ) ) ) {
87
+            $fromEncoding = self::mb_detect_encoding( $s, $fromEncoding );
88 88
         } else {
89
-            $fromEncoding = self::getEncoding($fromEncoding);
89
+            $fromEncoding = self::getEncoding( $fromEncoding );
90 90
         }
91 91
 
92
-        $toEncoding = self::getEncoding($toEncoding);
92
+        $toEncoding = self::getEncoding( $toEncoding );
93 93
 
94
-        if ('BASE64' === $fromEncoding) {
95
-            $s = base64_decode($s);
94
+        if ( 'BASE64' === $fromEncoding ) {
95
+            $s = base64_decode( $s );
96 96
             $fromEncoding = $toEncoding;
97 97
         }
98 98
 
99
-        if ('BASE64' === $toEncoding) {
100
-            return base64_encode($s);
99
+        if ( 'BASE64' === $toEncoding ) {
100
+            return base64_encode( $s );
101 101
         }
102 102
 
103
-        if ('HTML-ENTITIES' === $toEncoding || 'HTML' === $toEncoding) {
104
-            if ('HTML-ENTITIES' === $fromEncoding || 'HTML' === $fromEncoding) {
103
+        if ( 'HTML-ENTITIES' === $toEncoding || 'HTML' === $toEncoding ) {
104
+            if ( 'HTML-ENTITIES' === $fromEncoding || 'HTML' === $fromEncoding ) {
105 105
                 $fromEncoding = 'Windows-1252';
106 106
             }
107
-            if ('UTF-8' !== $fromEncoding) {
108
-                $s = \iconv($fromEncoding, 'UTF-8//IGNORE', $s);
107
+            if ( 'UTF-8' !== $fromEncoding ) {
108
+                $s = \iconv( $fromEncoding, 'UTF-8//IGNORE', $s );
109 109
             }
110 110
 
111
-            return preg_replace_callback('/[\x80-\xFF]+/', [__CLASS__, 'html_encoding_callback'], $s);
111
+            return preg_replace_callback( '/[\x80-\xFF]+/', [ __CLASS__, 'html_encoding_callback' ], $s );
112 112
         }
113 113
 
114
-        if ('HTML-ENTITIES' === $fromEncoding) {
115
-            $s = html_entity_decode($s, \ENT_COMPAT, 'UTF-8');
114
+        if ( 'HTML-ENTITIES' === $fromEncoding ) {
115
+            $s = html_entity_decode( $s, \ENT_COMPAT, 'UTF-8' );
116 116
             $fromEncoding = 'UTF-8';
117 117
         }
118 118
 
119
-        return \iconv($fromEncoding, $toEncoding.'//IGNORE', $s);
119
+        return \iconv( $fromEncoding, $toEncoding . '//IGNORE', $s );
120 120
     }
121 121
 
122
-    public static function mb_convert_variables($toEncoding, $fromEncoding, &...$vars)
122
+    public static function mb_convert_variables( $toEncoding, $fromEncoding, &...$vars )
123 123
     {
124 124
         $ok = true;
125
-        array_walk_recursive($vars, function (&$v) use (&$ok, $toEncoding, $fromEncoding) {
126
-            if (false === $v = self::mb_convert_encoding($v, $toEncoding, $fromEncoding)) {
125
+        array_walk_recursive( $vars, function( &$v ) use ( &$ok, $toEncoding, $fromEncoding ) {
126
+            if ( false === $v = self::mb_convert_encoding( $v, $toEncoding, $fromEncoding ) ) {
127 127
                 $ok = false;
128 128
             }
129 129
         });
@@ -131,210 +131,210 @@  discard block
 block discarded – undo
131 131
         return $ok ? $fromEncoding : false;
132 132
     }
133 133
 
134
-    public static function mb_decode_mimeheader($s)
134
+    public static function mb_decode_mimeheader( $s )
135 135
     {
136
-        return \iconv_mime_decode($s, 2, self::$internalEncoding);
136
+        return \iconv_mime_decode( $s, 2, self::$internalEncoding );
137 137
     }
138 138
 
139
-    public static function mb_encode_mimeheader($s, $charset = null, $transferEncoding = null, $linefeed = null, $indent = null)
139
+    public static function mb_encode_mimeheader( $s, $charset = null, $transferEncoding = null, $linefeed = null, $indent = null )
140 140
     {
141
-        trigger_error('mb_encode_mimeheader() is bugged. Please use iconv_mime_encode() instead', \E_USER_WARNING);
141
+        trigger_error( 'mb_encode_mimeheader() is bugged. Please use iconv_mime_encode() instead', \E_USER_WARNING );
142 142
     }
143 143
 
144
-    public static function mb_decode_numericentity($s, $convmap, $encoding = null)
144
+    public static function mb_decode_numericentity( $s, $convmap, $encoding = null )
145 145
     {
146
-        if (null !== $s && !is_scalar($s) && !(\is_object($s) && method_exists($s, '__toString'))) {
147
-            trigger_error('mb_decode_numericentity() expects parameter 1 to be string, '.\gettype($s).' given', \E_USER_WARNING);
146
+        if ( null !== $s && ! is_scalar( $s ) && ! ( \is_object( $s ) && method_exists( $s, '__toString' ) ) ) {
147
+            trigger_error( 'mb_decode_numericentity() expects parameter 1 to be string, ' . \gettype( $s ) . ' given', \E_USER_WARNING );
148 148
 
149 149
             return null;
150 150
         }
151 151
 
152
-        if (!\is_array($convmap) || (80000 > \PHP_VERSION_ID && !$convmap)) {
152
+        if ( ! \is_array( $convmap ) || ( 80000 > \PHP_VERSION_ID && ! $convmap ) ) {
153 153
             return false;
154 154
         }
155 155
 
156
-        if (null !== $encoding && !is_scalar($encoding)) {
157
-            trigger_error('mb_decode_numericentity() expects parameter 3 to be string, '.\gettype($s).' given', \E_USER_WARNING);
156
+        if ( null !== $encoding && ! is_scalar( $encoding ) ) {
157
+            trigger_error( 'mb_decode_numericentity() expects parameter 3 to be string, ' . \gettype( $s ) . ' given', \E_USER_WARNING );
158 158
 
159
-            return '';  // Instead of null (cf. mb_encode_numericentity).
159
+            return ''; // Instead of null (cf. mb_encode_numericentity).
160 160
         }
161 161
 
162
-        $s = (string) $s;
163
-        if ('' === $s) {
162
+        $s = (string)$s;
163
+        if ( '' === $s ) {
164 164
             return '';
165 165
         }
166 166
 
167
-        $encoding = self::getEncoding($encoding);
167
+        $encoding = self::getEncoding( $encoding );
168 168
 
169
-        if ('UTF-8' === $encoding) {
169
+        if ( 'UTF-8' === $encoding ) {
170 170
             $encoding = null;
171
-            if (!preg_match('//u', $s)) {
172
-                $s = @\iconv('UTF-8', 'UTF-8//IGNORE', $s);
171
+            if ( ! preg_match( '//u', $s ) ) {
172
+                $s = @\iconv( 'UTF-8', 'UTF-8//IGNORE', $s );
173 173
             }
174 174
         } else {
175
-            $s = \iconv($encoding, 'UTF-8//IGNORE', $s);
175
+            $s = \iconv( $encoding, 'UTF-8//IGNORE', $s );
176 176
         }
177 177
 
178
-        $cnt = floor(\count($convmap) / 4) * 4;
178
+        $cnt = floor( \count( $convmap ) / 4 ) * 4;
179 179
 
180
-        for ($i = 0; $i < $cnt; $i += 4) {
180
+        for ( $i = 0; $i < $cnt; $i += 4 ) {
181 181
             // collector_decode_htmlnumericentity ignores $convmap[$i + 3]
182
-            $convmap[$i] += $convmap[$i + 2];
183
-            $convmap[$i + 1] += $convmap[$i + 2];
182
+            $convmap[ $i ] += $convmap[ $i + 2 ];
183
+            $convmap[ $i + 1 ] += $convmap[ $i + 2 ];
184 184
         }
185 185
 
186
-        $s = preg_replace_callback('/&#(?:0*([0-9]+)|x0*([0-9a-fA-F]+))(?!&);?/', function (array $m) use ($cnt, $convmap) {
187
-            $c = isset($m[2]) ? (int) hexdec($m[2]) : $m[1];
188
-            for ($i = 0; $i < $cnt; $i += 4) {
189
-                if ($c >= $convmap[$i] && $c <= $convmap[$i + 1]) {
190
-                    return self::mb_chr($c - $convmap[$i + 2]);
186
+        $s = preg_replace_callback( '/&#(?:0*([0-9]+)|x0*([0-9a-fA-F]+))(?!&);?/', function( array $m ) use ( $cnt, $convmap ) {
187
+            $c = isset( $m[ 2 ] ) ? (int)hexdec( $m[ 2 ] ) : $m[ 1 ];
188
+            for ( $i = 0; $i < $cnt; $i += 4 ) {
189
+                if ( $c >= $convmap[ $i ] && $c <= $convmap[ $i + 1 ] ) {
190
+                    return self::mb_chr( $c - $convmap[ $i + 2 ] );
191 191
                 }
192 192
             }
193 193
 
194
-            return $m[0];
195
-        }, $s);
194
+            return $m[ 0 ];
195
+        }, $s );
196 196
 
197
-        if (null === $encoding) {
197
+        if ( null === $encoding ) {
198 198
             return $s;
199 199
         }
200 200
 
201
-        return \iconv('UTF-8', $encoding.'//IGNORE', $s);
201
+        return \iconv( 'UTF-8', $encoding . '//IGNORE', $s );
202 202
     }
203 203
 
204
-    public static function mb_encode_numericentity($s, $convmap, $encoding = null, $is_hex = false)
204
+    public static function mb_encode_numericentity( $s, $convmap, $encoding = null, $is_hex = false )
205 205
     {
206
-        if (null !== $s && !is_scalar($s) && !(\is_object($s) && method_exists($s, '__toString'))) {
207
-            trigger_error('mb_encode_numericentity() expects parameter 1 to be string, '.\gettype($s).' given', \E_USER_WARNING);
206
+        if ( null !== $s && ! is_scalar( $s ) && ! ( \is_object( $s ) && method_exists( $s, '__toString' ) ) ) {
207
+            trigger_error( 'mb_encode_numericentity() expects parameter 1 to be string, ' . \gettype( $s ) . ' given', \E_USER_WARNING );
208 208
 
209 209
             return null;
210 210
         }
211 211
 
212
-        if (!\is_array($convmap) || (80000 > \PHP_VERSION_ID && !$convmap)) {
212
+        if ( ! \is_array( $convmap ) || ( 80000 > \PHP_VERSION_ID && ! $convmap ) ) {
213 213
             return false;
214 214
         }
215 215
 
216
-        if (null !== $encoding && !is_scalar($encoding)) {
217
-            trigger_error('mb_encode_numericentity() expects parameter 3 to be string, '.\gettype($s).' given', \E_USER_WARNING);
216
+        if ( null !== $encoding && ! is_scalar( $encoding ) ) {
217
+            trigger_error( 'mb_encode_numericentity() expects parameter 3 to be string, ' . \gettype( $s ) . ' given', \E_USER_WARNING );
218 218
 
219
-            return null;  // Instead of '' (cf. mb_decode_numericentity).
219
+            return null; // Instead of '' (cf. mb_decode_numericentity).
220 220
         }
221 221
 
222
-        if (null !== $is_hex && !is_scalar($is_hex)) {
223
-            trigger_error('mb_encode_numericentity() expects parameter 4 to be boolean, '.\gettype($s).' given', \E_USER_WARNING);
222
+        if ( null !== $is_hex && ! is_scalar( $is_hex ) ) {
223
+            trigger_error( 'mb_encode_numericentity() expects parameter 4 to be boolean, ' . \gettype( $s ) . ' given', \E_USER_WARNING );
224 224
 
225 225
             return null;
226 226
         }
227 227
 
228
-        $s = (string) $s;
229
-        if ('' === $s) {
228
+        $s = (string)$s;
229
+        if ( '' === $s ) {
230 230
             return '';
231 231
         }
232 232
 
233
-        $encoding = self::getEncoding($encoding);
233
+        $encoding = self::getEncoding( $encoding );
234 234
 
235
-        if ('UTF-8' === $encoding) {
235
+        if ( 'UTF-8' === $encoding ) {
236 236
             $encoding = null;
237
-            if (!preg_match('//u', $s)) {
238
-                $s = @\iconv('UTF-8', 'UTF-8//IGNORE', $s);
237
+            if ( ! preg_match( '//u', $s ) ) {
238
+                $s = @\iconv( 'UTF-8', 'UTF-8//IGNORE', $s );
239 239
             }
240 240
         } else {
241
-            $s = \iconv($encoding, 'UTF-8//IGNORE', $s);
241
+            $s = \iconv( $encoding, 'UTF-8//IGNORE', $s );
242 242
         }
243 243
 
244
-        static $ulenMask = ["\xC0" => 2, "\xD0" => 2, "\xE0" => 3, "\xF0" => 4];
244
+        static $ulenMask = [ "\xC0" => 2, "\xD0" => 2, "\xE0" => 3, "\xF0" => 4 ];
245 245
 
246
-        $cnt = floor(\count($convmap) / 4) * 4;
246
+        $cnt = floor( \count( $convmap ) / 4 ) * 4;
247 247
         $i = 0;
248
-        $len = \strlen($s);
248
+        $len = \strlen( $s );
249 249
         $result = '';
250 250
 
251
-        while ($i < $len) {
252
-            $ulen = $s[$i] < "\x80" ? 1 : $ulenMask[$s[$i] & "\xF0"];
253
-            $uchr = substr($s, $i, $ulen);
251
+        while ( $i < $len ) {
252
+            $ulen = $s[ $i ] < "\x80" ? 1 : $ulenMask[ $s[ $i ] & "\xF0" ];
253
+            $uchr = substr( $s, $i, $ulen );
254 254
             $i += $ulen;
255
-            $c = self::mb_ord($uchr);
255
+            $c = self::mb_ord( $uchr );
256 256
 
257
-            for ($j = 0; $j < $cnt; $j += 4) {
258
-                if ($c >= $convmap[$j] && $c <= $convmap[$j + 1]) {
259
-                    $cOffset = ($c + $convmap[$j + 2]) & $convmap[$j + 3];
260
-                    $result .= $is_hex ? sprintf('&#x%X;', $cOffset) : '&#'.$cOffset.';';
257
+            for ( $j = 0; $j < $cnt; $j += 4 ) {
258
+                if ( $c >= $convmap[ $j ] && $c <= $convmap[ $j + 1 ] ) {
259
+                    $cOffset = ( $c + $convmap[ $j + 2 ] ) & $convmap[ $j + 3 ];
260
+                    $result .= $is_hex ? sprintf( '&#x%X;', $cOffset ) : '&#' . $cOffset . ';';
261 261
                     continue 2;
262 262
                 }
263 263
             }
264 264
             $result .= $uchr;
265 265
         }
266 266
 
267
-        if (null === $encoding) {
267
+        if ( null === $encoding ) {
268 268
             return $result;
269 269
         }
270 270
 
271
-        return \iconv('UTF-8', $encoding.'//IGNORE', $result);
271
+        return \iconv( 'UTF-8', $encoding . '//IGNORE', $result );
272 272
     }
273 273
 
274
-    public static function mb_convert_case($s, $mode, $encoding = null)
274
+    public static function mb_convert_case( $s, $mode, $encoding = null )
275 275
     {
276
-        $s = (string) $s;
277
-        if ('' === $s) {
276
+        $s = (string)$s;
277
+        if ( '' === $s ) {
278 278
             return '';
279 279
         }
280 280
 
281
-        $encoding = self::getEncoding($encoding);
281
+        $encoding = self::getEncoding( $encoding );
282 282
 
283
-        if ('UTF-8' === $encoding) {
283
+        if ( 'UTF-8' === $encoding ) {
284 284
             $encoding = null;
285
-            if (!preg_match('//u', $s)) {
286
-                $s = @\iconv('UTF-8', 'UTF-8//IGNORE', $s);
285
+            if ( ! preg_match( '//u', $s ) ) {
286
+                $s = @\iconv( 'UTF-8', 'UTF-8//IGNORE', $s );
287 287
             }
288 288
         } else {
289
-            $s = \iconv($encoding, 'UTF-8//IGNORE', $s);
289
+            $s = \iconv( $encoding, 'UTF-8//IGNORE', $s );
290 290
         }
291 291
 
292
-        if (\MB_CASE_TITLE == $mode) {
292
+        if ( \MB_CASE_TITLE == $mode ) {
293 293
             static $titleRegexp = null;
294
-            if (null === $titleRegexp) {
295
-                $titleRegexp = self::getData('titleCaseRegexp');
294
+            if ( null === $titleRegexp ) {
295
+                $titleRegexp = self::getData( 'titleCaseRegexp' );
296 296
             }
297
-            $s = preg_replace_callback($titleRegexp, [__CLASS__, 'title_case'], $s);
297
+            $s = preg_replace_callback( $titleRegexp, [ __CLASS__, 'title_case' ], $s );
298 298
         } else {
299
-            if (\MB_CASE_UPPER == $mode) {
299
+            if ( \MB_CASE_UPPER == $mode ) {
300 300
                 static $upper = null;
301
-                if (null === $upper) {
302
-                    $upper = self::getData('upperCase');
301
+                if ( null === $upper ) {
302
+                    $upper = self::getData( 'upperCase' );
303 303
                 }
304 304
                 $map = $upper;
305 305
             } else {
306
-                if (self::MB_CASE_FOLD === $mode) {
307
-                    $s = str_replace(self::CASE_FOLD[0], self::CASE_FOLD[1], $s);
306
+                if ( self::MB_CASE_FOLD === $mode ) {
307
+                    $s = str_replace( self::CASE_FOLD[ 0 ], self::CASE_FOLD[ 1 ], $s );
308 308
                 }
309 309
 
310 310
                 static $lower = null;
311
-                if (null === $lower) {
312
-                    $lower = self::getData('lowerCase');
311
+                if ( null === $lower ) {
312
+                    $lower = self::getData( 'lowerCase' );
313 313
                 }
314 314
                 $map = $lower;
315 315
             }
316 316
 
317
-            static $ulenMask = ["\xC0" => 2, "\xD0" => 2, "\xE0" => 3, "\xF0" => 4];
317
+            static $ulenMask = [ "\xC0" => 2, "\xD0" => 2, "\xE0" => 3, "\xF0" => 4 ];
318 318
 
319 319
             $i = 0;
320
-            $len = \strlen($s);
320
+            $len = \strlen( $s );
321 321
 
322
-            while ($i < $len) {
323
-                $ulen = $s[$i] < "\x80" ? 1 : $ulenMask[$s[$i] & "\xF0"];
324
-                $uchr = substr($s, $i, $ulen);
322
+            while ( $i < $len ) {
323
+                $ulen = $s[ $i ] < "\x80" ? 1 : $ulenMask[ $s[ $i ] & "\xF0" ];
324
+                $uchr = substr( $s, $i, $ulen );
325 325
                 $i += $ulen;
326 326
 
327
-                if (isset($map[$uchr])) {
328
-                    $uchr = $map[$uchr];
329
-                    $nlen = \strlen($uchr);
327
+                if ( isset( $map[ $uchr ] ) ) {
328
+                    $uchr = $map[ $uchr ];
329
+                    $nlen = \strlen( $uchr );
330 330
 
331
-                    if ($nlen == $ulen) {
331
+                    if ( $nlen == $ulen ) {
332 332
                         $nlen = $i;
333 333
                         do {
334
-                            $s[--$nlen] = $uchr[--$ulen];
335
-                        } while ($ulen);
334
+                            $s[--$nlen ] = $uchr[--$ulen ];
335
+                        } while ( $ulen );
336 336
                     } else {
337
-                        $s = substr_replace($s, $uchr, $i - $ulen, $ulen);
337
+                        $s = substr_replace( $s, $uchr, $i - $ulen, $ulen );
338 338
                         $len += $nlen - $ulen;
339 339
                         $i += $nlen - $ulen;
340 340
                     }
@@ -342,41 +342,41 @@  discard block
 block discarded – undo
342 342
             }
343 343
         }
344 344
 
345
-        if (null === $encoding) {
345
+        if ( null === $encoding ) {
346 346
             return $s;
347 347
         }
348 348
 
349
-        return \iconv('UTF-8', $encoding.'//IGNORE', $s);
349
+        return \iconv( 'UTF-8', $encoding . '//IGNORE', $s );
350 350
     }
351 351
 
352
-    public static function mb_internal_encoding($encoding = null)
352
+    public static function mb_internal_encoding( $encoding = null )
353 353
     {
354
-        if (null === $encoding) {
354
+        if ( null === $encoding ) {
355 355
             return self::$internalEncoding;
356 356
         }
357 357
 
358
-        $normalizedEncoding = self::getEncoding($encoding);
358
+        $normalizedEncoding = self::getEncoding( $encoding );
359 359
 
360
-        if ('UTF-8' === $normalizedEncoding || false !== @\iconv($normalizedEncoding, $normalizedEncoding, ' ')) {
360
+        if ( 'UTF-8' === $normalizedEncoding || false !== @\iconv( $normalizedEncoding, $normalizedEncoding, ' ' ) ) {
361 361
             self::$internalEncoding = $normalizedEncoding;
362 362
 
363 363
             return true;
364 364
         }
365 365
 
366
-        if (80000 > \PHP_VERSION_ID) {
366
+        if ( 80000 > \PHP_VERSION_ID ) {
367 367
             return false;
368 368
         }
369 369
 
370
-        throw new \ValueError(sprintf('Argument #1 ($encoding) must be a valid encoding, "%s" given', $encoding));
370
+        throw new \ValueError( sprintf( 'Argument #1 ($encoding) must be a valid encoding, "%s" given', $encoding ) );
371 371
     }
372 372
 
373
-    public static function mb_language($lang = null)
373
+    public static function mb_language( $lang = null )
374 374
     {
375
-        if (null === $lang) {
375
+        if ( null === $lang ) {
376 376
             return self::$language;
377 377
         }
378 378
 
379
-        switch ($normalizedLang = strtolower($lang)) {
379
+        switch ( $normalizedLang = strtolower( $lang ) ) {
380 380
             case 'uni':
381 381
             case 'neutral':
382 382
                 self::$language = $normalizedLang;
@@ -384,69 +384,69 @@  discard block
 block discarded – undo
384 384
                 return true;
385 385
         }
386 386
 
387
-        if (80000 > \PHP_VERSION_ID) {
387
+        if ( 80000 > \PHP_VERSION_ID ) {
388 388
             return false;
389 389
         }
390 390
 
391
-        throw new \ValueError(sprintf('Argument #1 ($language) must be a valid language, "%s" given', $lang));
391
+        throw new \ValueError( sprintf( 'Argument #1 ($language) must be a valid language, "%s" given', $lang ) );
392 392
     }
393 393
 
394 394
     public static function mb_list_encodings()
395 395
     {
396
-        return ['UTF-8'];
396
+        return [ 'UTF-8' ];
397 397
     }
398 398
 
399
-    public static function mb_encoding_aliases($encoding)
399
+    public static function mb_encoding_aliases( $encoding )
400 400
     {
401
-        switch (strtoupper($encoding)) {
401
+        switch ( strtoupper( $encoding ) ) {
402 402
             case 'UTF8':
403 403
             case 'UTF-8':
404
-                return ['utf8'];
404
+                return [ 'utf8' ];
405 405
         }
406 406
 
407 407
         return false;
408 408
     }
409 409
 
410
-    public static function mb_check_encoding($var = null, $encoding = null)
410
+    public static function mb_check_encoding( $var = null, $encoding = null )
411 411
     {
412
-        if (null === $encoding) {
413
-            if (null === $var) {
412
+        if ( null === $encoding ) {
413
+            if ( null === $var ) {
414 414
                 return false;
415 415
             }
416 416
             $encoding = self::$internalEncoding;
417 417
         }
418 418
 
419
-        return self::mb_detect_encoding($var, [$encoding]) || false !== @\iconv($encoding, $encoding, $var);
419
+        return self::mb_detect_encoding( $var, [ $encoding ] ) || false !== @\iconv( $encoding, $encoding, $var );
420 420
     }
421 421
 
422
-    public static function mb_detect_encoding($str, $encodingList = null, $strict = false)
422
+    public static function mb_detect_encoding( $str, $encodingList = null, $strict = false )
423 423
     {
424
-        if (null === $encodingList) {
424
+        if ( null === $encodingList ) {
425 425
             $encodingList = self::$encodingList;
426 426
         } else {
427
-            if (!\is_array($encodingList)) {
428
-                $encodingList = array_map('trim', explode(',', $encodingList));
427
+            if ( ! \is_array( $encodingList ) ) {
428
+                $encodingList = array_map( 'trim', explode( ',', $encodingList ) );
429 429
             }
430
-            $encodingList = array_map('strtoupper', $encodingList);
430
+            $encodingList = array_map( 'strtoupper', $encodingList );
431 431
         }
432 432
 
433
-        foreach ($encodingList as $enc) {
434
-            switch ($enc) {
433
+        foreach ( $encodingList as $enc ) {
434
+            switch ( $enc ) {
435 435
                 case 'ASCII':
436
-                    if (!preg_match('/[\x80-\xFF]/', $str)) {
436
+                    if ( ! preg_match( '/[\x80-\xFF]/', $str ) ) {
437 437
                         return $enc;
438 438
                     }
439 439
                     break;
440 440
 
441 441
                 case 'UTF8':
442 442
                 case 'UTF-8':
443
-                    if (preg_match('//u', $str)) {
443
+                    if ( preg_match( '//u', $str ) ) {
444 444
                         return 'UTF-8';
445 445
                     }
446 446
                     break;
447 447
 
448 448
                 default:
449
-                    if (0 === strncmp($enc, 'ISO-8859-', 9)) {
449
+                    if ( 0 === strncmp( $enc, 'ISO-8859-', 9 ) ) {
450 450
                         return $enc;
451 451
                     }
452 452
             }
@@ -455,21 +455,21 @@  discard block
 block discarded – undo
455 455
         return false;
456 456
     }
457 457
 
458
-    public static function mb_detect_order($encodingList = null)
458
+    public static function mb_detect_order( $encodingList = null )
459 459
     {
460
-        if (null === $encodingList) {
460
+        if ( null === $encodingList ) {
461 461
             return self::$encodingList;
462 462
         }
463 463
 
464
-        if (!\is_array($encodingList)) {
465
-            $encodingList = array_map('trim', explode(',', $encodingList));
464
+        if ( ! \is_array( $encodingList ) ) {
465
+            $encodingList = array_map( 'trim', explode( ',', $encodingList ) );
466 466
         }
467
-        $encodingList = array_map('strtoupper', $encodingList);
467
+        $encodingList = array_map( 'strtoupper', $encodingList );
468 468
 
469
-        foreach ($encodingList as $enc) {
470
-            switch ($enc) {
469
+        foreach ( $encodingList as $enc ) {
470
+            switch ( $enc ) {
471 471
                 default:
472
-                    if (strncmp($enc, 'ISO-8859-', 9)) {
472
+                    if ( strncmp( $enc, 'ISO-8859-', 9 ) ) {
473 473
                         return false;
474 474
                     }
475 475
                     // no break
@@ -484,27 +484,27 @@  discard block
 block discarded – undo
484 484
         return true;
485 485
     }
486 486
 
487
-    public static function mb_strlen($s, $encoding = null)
487
+    public static function mb_strlen( $s, $encoding = null )
488 488
     {
489
-        $encoding = self::getEncoding($encoding);
490
-        if ('CP850' === $encoding || 'ASCII' === $encoding) {
491
-            return \strlen($s);
489
+        $encoding = self::getEncoding( $encoding );
490
+        if ( 'CP850' === $encoding || 'ASCII' === $encoding ) {
491
+            return \strlen( $s );
492 492
         }
493 493
 
494
-        return @\iconv_strlen($s, $encoding);
494
+        return @\iconv_strlen( $s, $encoding );
495 495
     }
496 496
 
497
-    public static function mb_strpos($haystack, $needle, $offset = 0, $encoding = null)
497
+    public static function mb_strpos( $haystack, $needle, $offset = 0, $encoding = null )
498 498
     {
499
-        $encoding = self::getEncoding($encoding);
500
-        if ('CP850' === $encoding || 'ASCII' === $encoding) {
501
-            return strpos($haystack, $needle, $offset);
499
+        $encoding = self::getEncoding( $encoding );
500
+        if ( 'CP850' === $encoding || 'ASCII' === $encoding ) {
501
+            return strpos( $haystack, $needle, $offset );
502 502
         }
503 503
 
504
-        $needle = (string) $needle;
505
-        if ('' === $needle) {
506
-            if (80000 > \PHP_VERSION_ID) {
507
-                trigger_error(__METHOD__.': Empty delimiter', \E_USER_WARNING);
504
+        $needle = (string)$needle;
505
+        if ( '' === $needle ) {
506
+            if ( 80000 > \PHP_VERSION_ID ) {
507
+                trigger_error( __METHOD__ . ': Empty delimiter', \E_USER_WARNING );
508 508
 
509 509
                 return false;
510 510
             }
@@ -512,190 +512,190 @@  discard block
 block discarded – undo
512 512
             return 0;
513 513
         }
514 514
 
515
-        return \iconv_strpos($haystack, $needle, $offset, $encoding);
515
+        return \iconv_strpos( $haystack, $needle, $offset, $encoding );
516 516
     }
517 517
 
518
-    public static function mb_strrpos($haystack, $needle, $offset = 0, $encoding = null)
518
+    public static function mb_strrpos( $haystack, $needle, $offset = 0, $encoding = null )
519 519
     {
520
-        $encoding = self::getEncoding($encoding);
521
-        if ('CP850' === $encoding || 'ASCII' === $encoding) {
522
-            return strrpos($haystack, $needle, $offset);
520
+        $encoding = self::getEncoding( $encoding );
521
+        if ( 'CP850' === $encoding || 'ASCII' === $encoding ) {
522
+            return strrpos( $haystack, $needle, $offset );
523 523
         }
524 524
 
525
-        if ($offset != (int) $offset) {
525
+        if ( $offset != (int)$offset ) {
526 526
             $offset = 0;
527
-        } elseif ($offset = (int) $offset) {
528
-            if ($offset < 0) {
529
-                if (0 > $offset += self::mb_strlen($needle)) {
530
-                    $haystack = self::mb_substr($haystack, 0, $offset, $encoding);
527
+        } elseif ( $offset = (int)$offset ) {
528
+            if ( $offset < 0 ) {
529
+                if ( 0 > $offset += self::mb_strlen( $needle ) ) {
530
+                    $haystack = self::mb_substr( $haystack, 0, $offset, $encoding );
531 531
                 }
532 532
                 $offset = 0;
533 533
             } else {
534
-                $haystack = self::mb_substr($haystack, $offset, 2147483647, $encoding);
534
+                $haystack = self::mb_substr( $haystack, $offset, 2147483647, $encoding );
535 535
             }
536 536
         }
537 537
 
538 538
         $pos = '' !== $needle || 80000 > \PHP_VERSION_ID
539
-            ? \iconv_strrpos($haystack, $needle, $encoding)
540
-            : self::mb_strlen($haystack, $encoding);
539
+            ? \iconv_strrpos( $haystack, $needle, $encoding )
540
+            : self::mb_strlen( $haystack, $encoding );
541 541
 
542 542
         return false !== $pos ? $offset + $pos : false;
543 543
     }
544 544
 
545
-    public static function mb_str_split($string, $split_length = 1, $encoding = null)
545
+    public static function mb_str_split( $string, $split_length = 1, $encoding = null )
546 546
     {
547
-        if (null !== $string && !is_scalar($string) && !(\is_object($string) && method_exists($string, '__toString'))) {
548
-            trigger_error('mb_str_split() expects parameter 1 to be string, '.\gettype($string).' given', \E_USER_WARNING);
547
+        if ( null !== $string && ! is_scalar( $string ) && ! ( \is_object( $string ) && method_exists( $string, '__toString' ) ) ) {
548
+            trigger_error( 'mb_str_split() expects parameter 1 to be string, ' . \gettype( $string ) . ' given', \E_USER_WARNING );
549 549
 
550 550
             return null;
551 551
         }
552 552
 
553
-        if (1 > $split_length = (int) $split_length) {
554
-            if (80000 > \PHP_VERSION_ID) {
555
-                trigger_error('The length of each segment must be greater than zero', \E_USER_WARNING);
553
+        if ( 1 > $split_length = (int)$split_length ) {
554
+            if ( 80000 > \PHP_VERSION_ID ) {
555
+                trigger_error( 'The length of each segment must be greater than zero', \E_USER_WARNING );
556 556
                 return false;
557 557
             }
558 558
 
559
-            throw new \ValueError('Argument #2 ($length) must be greater than 0');
559
+            throw new \ValueError( 'Argument #2 ($length) must be greater than 0' );
560 560
         }
561 561
 
562
-        if (null === $encoding) {
562
+        if ( null === $encoding ) {
563 563
             $encoding = mb_internal_encoding();
564 564
         }
565 565
 
566
-        if ('UTF-8' === $encoding = self::getEncoding($encoding)) {
566
+        if ( 'UTF-8' === $encoding = self::getEncoding( $encoding ) ) {
567 567
             $rx = '/(';
568
-            while (65535 < $split_length) {
568
+            while ( 65535 < $split_length ) {
569 569
                 $rx .= '.{65535}';
570 570
                 $split_length -= 65535;
571 571
             }
572
-            $rx .= '.{'.$split_length.'})/us';
572
+            $rx .= '.{' . $split_length . '})/us';
573 573
 
574
-            return preg_split($rx, $string, -1, \PREG_SPLIT_DELIM_CAPTURE | \PREG_SPLIT_NO_EMPTY);
574
+            return preg_split( $rx, $string, -1, \PREG_SPLIT_DELIM_CAPTURE | \PREG_SPLIT_NO_EMPTY );
575 575
         }
576 576
 
577
-        $result = [];
578
-        $length = mb_strlen($string, $encoding);
577
+        $result = [ ];
578
+        $length = mb_strlen( $string, $encoding );
579 579
 
580
-        for ($i = 0; $i < $length; $i += $split_length) {
581
-            $result[] = mb_substr($string, $i, $split_length, $encoding);
580
+        for ( $i = 0; $i < $length; $i += $split_length ) {
581
+            $result[ ] = mb_substr( $string, $i, $split_length, $encoding );
582 582
         }
583 583
 
584 584
         return $result;
585 585
     }
586 586
 
587
-    public static function mb_strtolower($s, $encoding = null)
587
+    public static function mb_strtolower( $s, $encoding = null )
588 588
     {
589
-        return self::mb_convert_case($s, \MB_CASE_LOWER, $encoding);
589
+        return self::mb_convert_case( $s, \MB_CASE_LOWER, $encoding );
590 590
     }
591 591
 
592
-    public static function mb_strtoupper($s, $encoding = null)
592
+    public static function mb_strtoupper( $s, $encoding = null )
593 593
     {
594
-        return self::mb_convert_case($s, \MB_CASE_UPPER, $encoding);
594
+        return self::mb_convert_case( $s, \MB_CASE_UPPER, $encoding );
595 595
     }
596 596
 
597
-    public static function mb_substitute_character($c = null)
597
+    public static function mb_substitute_character( $c = null )
598 598
     {
599
-        if (null === $c) {
599
+        if ( null === $c ) {
600 600
             return 'none';
601 601
         }
602
-        if (0 === strcasecmp($c, 'none')) {
602
+        if ( 0 === strcasecmp( $c, 'none' ) ) {
603 603
             return true;
604 604
         }
605
-        if (80000 > \PHP_VERSION_ID) {
605
+        if ( 80000 > \PHP_VERSION_ID ) {
606 606
             return false;
607 607
         }
608
-        if (\is_int($c) || 'long' === $c || 'entity' === $c) {
608
+        if ( \is_int( $c ) || 'long' === $c || 'entity' === $c ) {
609 609
             return false;
610 610
         }
611 611
 
612
-        throw new \ValueError('Argument #1 ($substitute_character) must be "none", "long", "entity" or a valid codepoint');
612
+        throw new \ValueError( 'Argument #1 ($substitute_character) must be "none", "long", "entity" or a valid codepoint' );
613 613
     }
614 614
 
615
-    public static function mb_substr($s, $start, $length = null, $encoding = null)
615
+    public static function mb_substr( $s, $start, $length = null, $encoding = null )
616 616
     {
617
-        $encoding = self::getEncoding($encoding);
618
-        if ('CP850' === $encoding || 'ASCII' === $encoding) {
619
-            return (string) substr($s, $start, null === $length ? 2147483647 : $length);
617
+        $encoding = self::getEncoding( $encoding );
618
+        if ( 'CP850' === $encoding || 'ASCII' === $encoding ) {
619
+            return (string)substr( $s, $start, null === $length ? 2147483647 : $length );
620 620
         }
621 621
 
622
-        if ($start < 0) {
623
-            $start = \iconv_strlen($s, $encoding) + $start;
624
-            if ($start < 0) {
622
+        if ( $start < 0 ) {
623
+            $start = \iconv_strlen( $s, $encoding ) + $start;
624
+            if ( $start < 0 ) {
625 625
                 $start = 0;
626 626
             }
627 627
         }
628 628
 
629
-        if (null === $length) {
629
+        if ( null === $length ) {
630 630
             $length = 2147483647;
631
-        } elseif ($length < 0) {
632
-            $length = \iconv_strlen($s, $encoding) + $length - $start;
633
-            if ($length < 0) {
631
+        } elseif ( $length < 0 ) {
632
+            $length = \iconv_strlen( $s, $encoding ) + $length - $start;
633
+            if ( $length < 0 ) {
634 634
                 return '';
635 635
             }
636 636
         }
637 637
 
638
-        return (string) \iconv_substr($s, $start, $length, $encoding);
638
+        return (string)\iconv_substr( $s, $start, $length, $encoding );
639 639
     }
640 640
 
641
-    public static function mb_stripos($haystack, $needle, $offset = 0, $encoding = null)
641
+    public static function mb_stripos( $haystack, $needle, $offset = 0, $encoding = null )
642 642
     {
643
-        $haystack = self::mb_convert_case($haystack, self::MB_CASE_FOLD, $encoding);
644
-        $needle = self::mb_convert_case($needle, self::MB_CASE_FOLD, $encoding);
643
+        $haystack = self::mb_convert_case( $haystack, self::MB_CASE_FOLD, $encoding );
644
+        $needle = self::mb_convert_case( $needle, self::MB_CASE_FOLD, $encoding );
645 645
 
646
-        return self::mb_strpos($haystack, $needle, $offset, $encoding);
646
+        return self::mb_strpos( $haystack, $needle, $offset, $encoding );
647 647
     }
648 648
 
649
-    public static function mb_stristr($haystack, $needle, $part = false, $encoding = null)
649
+    public static function mb_stristr( $haystack, $needle, $part = false, $encoding = null )
650 650
     {
651
-        $pos = self::mb_stripos($haystack, $needle, 0, $encoding);
651
+        $pos = self::mb_stripos( $haystack, $needle, 0, $encoding );
652 652
 
653
-        return self::getSubpart($pos, $part, $haystack, $encoding);
653
+        return self::getSubpart( $pos, $part, $haystack, $encoding );
654 654
     }
655 655
 
656
-    public static function mb_strrchr($haystack, $needle, $part = false, $encoding = null)
656
+    public static function mb_strrchr( $haystack, $needle, $part = false, $encoding = null )
657 657
     {
658
-        $encoding = self::getEncoding($encoding);
659
-        if ('CP850' === $encoding || 'ASCII' === $encoding) {
660
-            $pos = strrpos($haystack, $needle);
658
+        $encoding = self::getEncoding( $encoding );
659
+        if ( 'CP850' === $encoding || 'ASCII' === $encoding ) {
660
+            $pos = strrpos( $haystack, $needle );
661 661
         } else {
662
-            $needle = self::mb_substr($needle, 0, 1, $encoding);
663
-            $pos = \iconv_strrpos($haystack, $needle, $encoding);
662
+            $needle = self::mb_substr( $needle, 0, 1, $encoding );
663
+            $pos = \iconv_strrpos( $haystack, $needle, $encoding );
664 664
         }
665 665
 
666
-        return self::getSubpart($pos, $part, $haystack, $encoding);
666
+        return self::getSubpart( $pos, $part, $haystack, $encoding );
667 667
     }
668 668
 
669
-    public static function mb_strrichr($haystack, $needle, $part = false, $encoding = null)
669
+    public static function mb_strrichr( $haystack, $needle, $part = false, $encoding = null )
670 670
     {
671
-        $needle = self::mb_substr($needle, 0, 1, $encoding);
672
-        $pos = self::mb_strripos($haystack, $needle, $encoding);
671
+        $needle = self::mb_substr( $needle, 0, 1, $encoding );
672
+        $pos = self::mb_strripos( $haystack, $needle, $encoding );
673 673
 
674
-        return self::getSubpart($pos, $part, $haystack, $encoding);
674
+        return self::getSubpart( $pos, $part, $haystack, $encoding );
675 675
     }
676 676
 
677
-    public static function mb_strripos($haystack, $needle, $offset = 0, $encoding = null)
677
+    public static function mb_strripos( $haystack, $needle, $offset = 0, $encoding = null )
678 678
     {
679
-        $haystack = self::mb_convert_case($haystack, self::MB_CASE_FOLD, $encoding);
680
-        $needle = self::mb_convert_case($needle, self::MB_CASE_FOLD, $encoding);
679
+        $haystack = self::mb_convert_case( $haystack, self::MB_CASE_FOLD, $encoding );
680
+        $needle = self::mb_convert_case( $needle, self::MB_CASE_FOLD, $encoding );
681 681
 
682
-        return self::mb_strrpos($haystack, $needle, $offset, $encoding);
682
+        return self::mb_strrpos( $haystack, $needle, $offset, $encoding );
683 683
     }
684 684
 
685
-    public static function mb_strstr($haystack, $needle, $part = false, $encoding = null)
685
+    public static function mb_strstr( $haystack, $needle, $part = false, $encoding = null )
686 686
     {
687
-        $pos = strpos($haystack, $needle);
688
-        if (false === $pos) {
687
+        $pos = strpos( $haystack, $needle );
688
+        if ( false === $pos ) {
689 689
             return false;
690 690
         }
691
-        if ($part) {
692
-            return substr($haystack, 0, $pos);
691
+        if ( $part ) {
692
+            return substr( $haystack, 0, $pos );
693 693
         }
694 694
 
695
-        return substr($haystack, $pos);
695
+        return substr( $haystack, $pos );
696 696
     }
697 697
 
698
-    public static function mb_get_info($type = 'all')
698
+    public static function mb_get_info( $type = 'all' )
699 699
     {
700 700
         $info = [
701 701
             'internal_encoding' => self::$internalEncoding,
@@ -714,160 +714,160 @@  discard block
 block discarded – undo
714 714
             'strict_detection' => 'Off',
715 715
         ];
716 716
 
717
-        if ('all' === $type) {
717
+        if ( 'all' === $type ) {
718 718
             return $info;
719 719
         }
720
-        if (isset($info[$type])) {
721
-            return $info[$type];
720
+        if ( isset( $info[ $type ] ) ) {
721
+            return $info[ $type ];
722 722
         }
723 723
 
724 724
         return false;
725 725
     }
726 726
 
727
-    public static function mb_http_input($type = '')
727
+    public static function mb_http_input( $type = '' )
728 728
     {
729 729
         return false;
730 730
     }
731 731
 
732
-    public static function mb_http_output($encoding = null)
732
+    public static function mb_http_output( $encoding = null )
733 733
     {
734 734
         return null !== $encoding ? 'pass' === $encoding : 'pass';
735 735
     }
736 736
 
737
-    public static function mb_strwidth($s, $encoding = null)
737
+    public static function mb_strwidth( $s, $encoding = null )
738 738
     {
739
-        $encoding = self::getEncoding($encoding);
739
+        $encoding = self::getEncoding( $encoding );
740 740
 
741
-        if ('UTF-8' !== $encoding) {
742
-            $s = \iconv($encoding, 'UTF-8//IGNORE', $s);
741
+        if ( 'UTF-8' !== $encoding ) {
742
+            $s = \iconv( $encoding, 'UTF-8//IGNORE', $s );
743 743
         }
744 744
 
745
-        $s = preg_replace('/[\x{1100}-\x{115F}\x{2329}\x{232A}\x{2E80}-\x{303E}\x{3040}-\x{A4CF}\x{AC00}-\x{D7A3}\x{F900}-\x{FAFF}\x{FE10}-\x{FE19}\x{FE30}-\x{FE6F}\x{FF00}-\x{FF60}\x{FFE0}-\x{FFE6}\x{20000}-\x{2FFFD}\x{30000}-\x{3FFFD}]/u', '', $s, -1, $wide);
745
+        $s = preg_replace( '/[\x{1100}-\x{115F}\x{2329}\x{232A}\x{2E80}-\x{303E}\x{3040}-\x{A4CF}\x{AC00}-\x{D7A3}\x{F900}-\x{FAFF}\x{FE10}-\x{FE19}\x{FE30}-\x{FE6F}\x{FF00}-\x{FF60}\x{FFE0}-\x{FFE6}\x{20000}-\x{2FFFD}\x{30000}-\x{3FFFD}]/u', '', $s, -1, $wide );
746 746
 
747
-        return ($wide << 1) + \iconv_strlen($s, 'UTF-8');
747
+        return ( $wide << 1 ) + \iconv_strlen( $s, 'UTF-8' );
748 748
     }
749 749
 
750
-    public static function mb_substr_count($haystack, $needle, $encoding = null)
750
+    public static function mb_substr_count( $haystack, $needle, $encoding = null )
751 751
     {
752
-        return substr_count($haystack, $needle);
752
+        return substr_count( $haystack, $needle );
753 753
     }
754 754
 
755
-    public static function mb_output_handler($contents, $status)
755
+    public static function mb_output_handler( $contents, $status )
756 756
     {
757 757
         return $contents;
758 758
     }
759 759
 
760
-    public static function mb_chr($code, $encoding = null)
760
+    public static function mb_chr( $code, $encoding = null )
761 761
     {
762
-        if (0x80 > $code %= 0x200000) {
763
-            $s = \chr($code);
764
-        } elseif (0x800 > $code) {
765
-            $s = \chr(0xC0 | $code >> 6).\chr(0x80 | $code & 0x3F);
766
-        } elseif (0x10000 > $code) {
767
-            $s = \chr(0xE0 | $code >> 12).\chr(0x80 | $code >> 6 & 0x3F).\chr(0x80 | $code & 0x3F);
762
+        if ( 0x80 > $code %= 0x200000 ) {
763
+            $s = \chr( $code );
764
+        } elseif ( 0x800 > $code ) {
765
+            $s = \chr( 0xC0 | $code >> 6 ) . \chr( 0x80 | $code & 0x3F );
766
+        } elseif ( 0x10000 > $code ) {
767
+            $s = \chr( 0xE0 | $code >> 12 ) . \chr( 0x80 | $code >> 6 & 0x3F ) . \chr( 0x80 | $code & 0x3F );
768 768
         } else {
769
-            $s = \chr(0xF0 | $code >> 18).\chr(0x80 | $code >> 12 & 0x3F).\chr(0x80 | $code >> 6 & 0x3F).\chr(0x80 | $code & 0x3F);
769
+            $s = \chr( 0xF0 | $code >> 18 ) . \chr( 0x80 | $code >> 12 & 0x3F ) . \chr( 0x80 | $code >> 6 & 0x3F ) . \chr( 0x80 | $code & 0x3F );
770 770
         }
771 771
 
772
-        if ('UTF-8' !== $encoding = self::getEncoding($encoding)) {
773
-            $s = mb_convert_encoding($s, $encoding, 'UTF-8');
772
+        if ( 'UTF-8' !== $encoding = self::getEncoding( $encoding ) ) {
773
+            $s = mb_convert_encoding( $s, $encoding, 'UTF-8' );
774 774
         }
775 775
 
776 776
         return $s;
777 777
     }
778 778
 
779
-    public static function mb_ord($s, $encoding = null)
779
+    public static function mb_ord( $s, $encoding = null )
780 780
     {
781
-        if ('UTF-8' !== $encoding = self::getEncoding($encoding)) {
782
-            $s = mb_convert_encoding($s, 'UTF-8', $encoding);
781
+        if ( 'UTF-8' !== $encoding = self::getEncoding( $encoding ) ) {
782
+            $s = mb_convert_encoding( $s, 'UTF-8', $encoding );
783 783
         }
784 784
 
785
-        if (1 === \strlen($s)) {
786
-            return \ord($s);
785
+        if ( 1 === \strlen( $s ) ) {
786
+            return \ord( $s );
787 787
         }
788 788
 
789
-        $code = ($s = unpack('C*', substr($s, 0, 4))) ? $s[1] : 0;
790
-        if (0xF0 <= $code) {
791
-            return (($code - 0xF0) << 18) + (($s[2] - 0x80) << 12) + (($s[3] - 0x80) << 6) + $s[4] - 0x80;
789
+        $code = ( $s = unpack( 'C*', substr( $s, 0, 4 ) ) ) ? $s[ 1 ] : 0;
790
+        if ( 0xF0 <= $code ) {
791
+            return ( ( $code - 0xF0 ) << 18 ) + ( ( $s[ 2 ] - 0x80 ) << 12 ) + ( ( $s[ 3 ] - 0x80 ) << 6 ) + $s[ 4 ] - 0x80;
792 792
         }
793
-        if (0xE0 <= $code) {
794
-            return (($code - 0xE0) << 12) + (($s[2] - 0x80) << 6) + $s[3] - 0x80;
793
+        if ( 0xE0 <= $code ) {
794
+            return ( ( $code - 0xE0 ) << 12 ) + ( ( $s[ 2 ] - 0x80 ) << 6 ) + $s[ 3 ] - 0x80;
795 795
         }
796
-        if (0xC0 <= $code) {
797
-            return (($code - 0xC0) << 6) + $s[2] - 0x80;
796
+        if ( 0xC0 <= $code ) {
797
+            return ( ( $code - 0xC0 ) << 6 ) + $s[ 2 ] - 0x80;
798 798
         }
799 799
 
800 800
         return $code;
801 801
     }
802 802
 
803
-    private static function getSubpart($pos, $part, $haystack, $encoding)
803
+    private static function getSubpart( $pos, $part, $haystack, $encoding )
804 804
     {
805
-        if (false === $pos) {
805
+        if ( false === $pos ) {
806 806
             return false;
807 807
         }
808
-        if ($part) {
809
-            return self::mb_substr($haystack, 0, $pos, $encoding);
808
+        if ( $part ) {
809
+            return self::mb_substr( $haystack, 0, $pos, $encoding );
810 810
         }
811 811
 
812
-        return self::mb_substr($haystack, $pos, null, $encoding);
812
+        return self::mb_substr( $haystack, $pos, null, $encoding );
813 813
     }
814 814
 
815
-    private static function html_encoding_callback(array $m)
815
+    private static function html_encoding_callback( array $m )
816 816
     {
817 817
         $i = 1;
818 818
         $entities = '';
819
-        $m = unpack('C*', htmlentities($m[0], \ENT_COMPAT, 'UTF-8'));
819
+        $m = unpack( 'C*', htmlentities( $m[ 0 ], \ENT_COMPAT, 'UTF-8' ) );
820 820
 
821
-        while (isset($m[$i])) {
822
-            if (0x80 > $m[$i]) {
823
-                $entities .= \chr($m[$i++]);
821
+        while ( isset( $m[ $i ] ) ) {
822
+            if ( 0x80 > $m[ $i ] ) {
823
+                $entities .= \chr( $m[ $i++ ] );
824 824
                 continue;
825 825
             }
826
-            if (0xF0 <= $m[$i]) {
827
-                $c = (($m[$i++] - 0xF0) << 18) + (($m[$i++] - 0x80) << 12) + (($m[$i++] - 0x80) << 6) + $m[$i++] - 0x80;
828
-            } elseif (0xE0 <= $m[$i]) {
829
-                $c = (($m[$i++] - 0xE0) << 12) + (($m[$i++] - 0x80) << 6) + $m[$i++] - 0x80;
826
+            if ( 0xF0 <= $m[ $i ] ) {
827
+                $c = ( ( $m[ $i++ ] - 0xF0 ) << 18 ) + ( ( $m[ $i++ ] - 0x80 ) << 12 ) + ( ( $m[ $i++ ] - 0x80 ) << 6 ) + $m[ $i++ ] - 0x80;
828
+            } elseif ( 0xE0 <= $m[ $i ] ) {
829
+                $c = ( ( $m[ $i++ ] - 0xE0 ) << 12 ) + ( ( $m[ $i++ ] - 0x80 ) << 6 ) + $m[ $i++ ] - 0x80;
830 830
             } else {
831
-                $c = (($m[$i++] - 0xC0) << 6) + $m[$i++] - 0x80;
831
+                $c = ( ( $m[ $i++ ] - 0xC0 ) << 6 ) + $m[ $i++ ] - 0x80;
832 832
             }
833 833
 
834
-            $entities .= '&#'.$c.';';
834
+            $entities .= '&#' . $c . ';';
835 835
         }
836 836
 
837 837
         return $entities;
838 838
     }
839 839
 
840
-    private static function title_case(array $s)
840
+    private static function title_case( array $s )
841 841
     {
842
-        return self::mb_convert_case($s[1], \MB_CASE_UPPER, 'UTF-8').self::mb_convert_case($s[2], \MB_CASE_LOWER, 'UTF-8');
842
+        return self::mb_convert_case( $s[ 1 ], \MB_CASE_UPPER, 'UTF-8' ) . self::mb_convert_case( $s[ 2 ], \MB_CASE_LOWER, 'UTF-8' );
843 843
     }
844 844
 
845
-    private static function getData($file)
845
+    private static function getData( $file )
846 846
     {
847
-        if (file_exists($file = __DIR__.'/Resources/unidata/'.$file.'.php')) {
847
+        if ( file_exists( $file = __DIR__ . '/Resources/unidata/' . $file . '.php' ) ) {
848 848
             return require $file;
849 849
         }
850 850
 
851 851
         return false;
852 852
     }
853 853
 
854
-    private static function getEncoding($encoding)
854
+    private static function getEncoding( $encoding )
855 855
     {
856
-        if (null === $encoding) {
856
+        if ( null === $encoding ) {
857 857
             return self::$internalEncoding;
858 858
         }
859 859
 
860
-        if ('UTF-8' === $encoding) {
860
+        if ( 'UTF-8' === $encoding ) {
861 861
             return 'UTF-8';
862 862
         }
863 863
 
864
-        $encoding = strtoupper($encoding);
864
+        $encoding = strtoupper( $encoding );
865 865
 
866
-        if ('8BIT' === $encoding || 'BINARY' === $encoding) {
866
+        if ( '8BIT' === $encoding || 'BINARY' === $encoding ) {
867 867
             return 'CP850';
868 868
         }
869 869
 
870
-        if ('UTF8' === $encoding) {
870
+        if ( 'UTF8' === $encoding ) {
871 871
             return 'UTF-8';
872 872
         }
873 873
 
Please login to merge, or discard this patch.
class-gravityview-plugin-hooks-gravity-forms-dropbox.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -52,7 +52,7 @@
 block discarded – undo
52 52
 		}
53 53
 
54 54
 		// The image source has ?raw=1; don't check for valid image extensions.
55
-		$image_atts['validate_src'] = false;
55
+		$image_atts[ 'validate_src' ] = false;
56 56
 
57 57
 		return $image_atts;
58 58
 	}
Please login to merge, or discard this patch.