Completed
Branch master (91fc81)
by Lars
22:28
created

Arrayy::max()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 8
ccs 4
cts 4
cp 1
rs 9.4285
cc 2
eloc 4
nc 2
nop 0
crap 2
1
<?php
2
3
namespace Arrayy;
4
5
use ArrayAccess;
6
use voku\helper\UTF8;
7
8
/**
9
 * Methods to manage arrays.
10
 */
11
class Arrayy extends CollectionMethods implements \Countable, \IteratorAggregate, \ArrayAccess
12
{
13
14
  /**
15
   * @var array
16
   */
17
  private $array = array();
18
19
  /**
20
   * Initializes
21
   *
22
   * @param array $array
23
   */
24 244
  public function __construct($array = array())
25
  {
26 244
    if (!$array) {
0 ignored issues
show
Bug Best Practice introduced by
The expression $array of type array is implicitly converted to a boolean; are you sure this is intended? If so, consider using empty($expr) instead to make it clear that you intend to check for an array without elements.

This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent.

Consider making the comparison explicit by using empty(..) or ! empty(...) instead.

Loading history...
27 52
      $array = array();
28 52
    }
29
30
    if (
31 244
        is_string($array)
32
        ||
33 244
        (is_object($array) && method_exists($array, '__toString'))
34 244
    ) {
35 1
      $array = (array)$array;
36 1
    }
37
38 244
    if (!is_array($array)) {
39 2
      throw new \InvalidArgumentException(
40
          'Passed value must be a array'
41 2
      );
42
    }
43
44 242
    $this->array = $array;
45 242
  }
46
47
  /**
48
   * magic to string
49
   *
50
   * @return string
51
   */
52 13
  public function __toString()
53
  {
54 13
    return $this->implode(',');
55
  }
56
57
  /**
58
   * Get a data by key
59
   *
60
   * @param $key
61
   *
62
   * @return mixed
63
   */
64
  public function &__get($key)
65
  {
66
    return $this->array[$key];
67
  }
68
69
  /**
70
   * Assigns a value to the specified data
71
   *
72
   * @param $key
73
   * @param $value
74
   */
75
  public function __set($key, $value)
76
  {
77
    $this->array[$key] = $value;
78
  }
79
80
  /**
81
   * Whether or not an data exists by key
82
   *
83
   * @param $key
84
   *
85
   * @return bool
86
   */
87
  public function __isset($key)
88
  {
89
    return isset($this->array[$key]);
90
  }
91
92
  /**
93
   * Unsets an data by key
94
   *
95
   * @param mixed $key
96
   */
97
  public function __unset($key)
98
  {
99
    unset($this->array[$key]);
100
  }
101
102
  /**
103
   * Assigns a value to the specified offset
104
   *
105
   *
106
   * @param mixed $offset
107
   * @param mixed $value
108
   */
109
  public function offsetSet($offset, $value)
110
  {
111
    if (null === $offset) {
112
      $this->array[] = $value;
113
    } else {
114
      $this->array[$offset] = $value;
115
    }
116
  }
117
118
  /**
119
   * Whether or not an offset exists
120
   *
121
   * @param mixed $offset
122
   *
123
   * @return bool
124
   */
125 3
  public function offsetExists($offset)
126
  {
127 3
    return isset($this->array[$offset]);
128
  }
129
130
  /**
131
   * Unsets an offset
132
   *
133
   * @param mixed $offset
134
   */
135
  public function offsetUnset($offset)
136
  {
137
    if ($this->offsetExists($offset)) {
138
      unset($this->array[$offset]);
139
    }
140
  }
141
142
  /**
143
   * Returns the value at specified offset
144
   *
145
   * @param mixed $offset
146
   *
147
   * @return null
148
   */
149 3
  public function offsetGet($offset)
150
  {
151 3
    return $this->offsetExists($offset) ? $this->array[$offset] : null;
152
  }
153
154
  /**
155
   * Returns a new ArrayIterator, thus implementing the IteratorAggregate
156
   * interface.
157
   *
158
   * @return \ArrayIterator An iterator for the values in the array
159
   */
160 1
  public function getIterator()
161
  {
162 1
    return new \ArrayIterator($this->array);
163
  }
164
165
  /**
166
   * call object as function
167
   *
168
   * @param mixed $key
169
   *
170
   * @return mixed
171
   */
172
  public function __invoke($key = null)
173
  {
174
    if ($key !== null) {
175
      if (isset($this->array[$key])) {
176
        return $this->array[$key];
177
      } else {
178
        return false;
179
      }
180
    }
181
182
    return (array)$this->array;
183
  }
184
185
  /**
186
   * get the current array from the "Arrayy"-object
187
   *
188
   * @return array
189
   */
190 144
  public function getArray()
191
  {
192 144
    return $this->array;
193
  }
194
195
  /**
196
   * Creates a Arrayy object
197
   *
198
   * @param array $array
199
   *
200
   * @return self
201
   */
202 185
  public static function create($array = array())
203
  {
204 185
    return new static($array);
205
  }
206
207
  ////////////////////////////////////////////////////////////////////
208
  ///////////////////////////// ANALYZE //////////////////////////////
209
  ////////////////////////////////////////////////////////////////////
210
211
  /**
212
   * Search for the value of the current array via $index.
213
   *
214
   * @param mixed $index
215
   *
216
   * @return self
217
   */
218 7
  public function searchValue($index)
219
  {
220
    // init
221 7
    $return = array();
222
223 7
    if (null !== $index) {
224 7
      $keyExists = isset($this->array[$index]);
225
226 7
      if ($keyExists !== false) {
227 5
        $return = array($this->array[$index]);
228 5
      }
229 7
    }
230
231 7
    return self::create((array)$return);
232
  }
233
234
  /**
235
   * Search for the index of the current array via $value.
236
   *
237
   * @param mixed $value
238
   *
239
   * @return self
240
   */
241 7
  public function searchIndex($value)
242
  {
243 7
    $key = array_search($value, $this->array, true);
244
245 7
    if ($key === false) {
246 2
      $return = array();
247 2
    } else {
248 5
      $return = array($key);
249
    }
250
251 7
    return self::create((array)$return);
252
  }
253
254
  /**
255
   * Check if all items in an array match a truth test.
256
   *
257
   * @param \Closure $closure
258
   *
259
   * @return bool
260
   */
261 8 View Code Duplication
  public function matches(\Closure $closure)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
262
  {
263
    // Reduce the array to only booleans
264 8
    $array = $this->each($closure);
265
266
    // Check the results
267 8
    if (count($array) === 0) {
268 2
      return true;
269
    }
270 6
    $array = array_search(false, $array, false);
271
272 6
    return is_bool($array);
273
  }
274
275
  /**
276
   * Check if any item in an array matches a truth test.
277
   *
278
   * @param \Closure $closure
279
   *
280
   * @return bool
281
   */
282 8 View Code Duplication
  public function matchesAny(\Closure $closure)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
283
  {
284
    // Reduce the array to only booleans
285 8
    $array = $this->each($closure);
286
287
    // Check the results
288 8
    if (count($array) === 0) {
289 2
      return true;
290
    }
291 6
    $array = array_search(true, $array, false);
292
293 6
    return is_int($array);
294
  }
295
296
  /**
297
   * Check if an item is in an array.
298
   *
299
   * @param mixed $value
300
   *
301
   * @return bool
302
   */
303 9
  public function contains($value)
304
  {
305 9
    return in_array($value, $this->array, true);
306
  }
307
308
  /**
309
   * Returns the average value of an array.
310
   *
311
   * @param int $decimals The number of decimals to return
312
   *
313
   * @return int The average value
314
   */
315 10
  public function average($decimals = null)
316
  {
317 10
    $count = $this->count();
318
319 10
    if (!$count) {
320 2
      return 0;
321
    }
322
323 8
    if (!is_int($decimals)) {
324 3
      $decimals = null;
325 3
    }
326
327 8
    return round(array_sum($this->array) / $count, $decimals);
328
  }
329
330
  /**
331
   * Count the values from the current array.
332
   *
333
   * INFO: only a alias for "$arrayy->size()"
334
   *
335
   * @return int
336
   */
337
  public function length()
338
  {
339
    return $this->size();
340
  }
341
342
  /**
343
   * Count the values from the current array.
344
   *
345
   * INFO: only a alias for "$arrayy->size()"
346
   *
347
   * @return int
348
   */
349 40
  public function count()
350
  {
351 40
    return $this->size();
352
  }
353
354
  /**
355
   * Get the size of an array.
356
   *
357
   * @return int
358
   */
359 40
  public function size()
360
  {
361 40
    return count($this->array);
362
  }
363
364
  /**
365
   * Get the max value from an array.
366
   *
367
   * @return mixed
368
   */
369 10
  public function max()
370
  {
371 10
    if ($this->count() === 0) {
372 1
      return false;
373
    }
374
375 9
    return max($this->array);
376
  }
377
378
  /**
379
   * Get the min value from an array.
380
   *
381
   * @return mixed
382
   */
383 10
  public function min()
384
  {
385 10
    if ($this->count() === 0) {
386 1
      return false;
387
    }
388
389 9
    return min($this->array);
390
  }
391
392
  ////////////////////////////////////////////////////////////////////
393
  //////////////////////////// FETCH FROM ////////////////////////////
394
  ////////////////////////////////////////////////////////////////////
395
396
  /**
397
   * Find the first item in an array that passes the truth test,
398
   *  otherwise return false
399
   *
400
   * @param \Closure $closure
401
   *
402
   * @return mixed|false false if we couldn't find the value
403
   */
404 7
  public function find(\Closure $closure)
405
  {
406 7
    foreach ($this->array as $key => $value) {
407 5
      if ($closure($value, $key)) {
408 4
        return $value;
409
      }
410 4
    }
411
412 3
    return false;
413
  }
414
415
  /**
416
   * Clean all falsy values from an array.
417
   *
418
   * @return self
419
   */
420 7
  public function clean()
421
  {
422 7
    return $this->filter(
423
        function ($value) {
424 6
          return (bool)$value;
425
        }
426 7
    );
427
  }
428
429
  /**
430
   * Get a random string from an array.
431
   *
432
   * @param null $take
433
   *
434
   * @return self
435
   */
436 5
  public function random($take = null)
437
  {
438 5
    if ($take !== null) {
439
      return $this->array[array_rand($this->array)];
440
    }
441
442 5
    shuffle($this->array);
443
444 5
    return $this->first($take);
445
  }
446
447
  /**
448
   * Return an array with all elements found in input array.
449
   *
450
   * @param array $search
451
   *
452
   * @return self
453
   */
454 2
  public function intersection(array $search)
455
  {
456 2
    return self::create(array_values(array_intersect($this->array, $search)));
457
  }
458
459
  /**
460
   * Return a boolean flag which indicates whether the two input arrays have any common elements.
461
   *
462
   * @param array $search
463
   *
464
   * @return bool
465
   */
466 1
  public function intersects(array $search)
467
  {
468 1
    return count($this->intersection($search)->array) > 0;
469
  }
470
471
  ////////////////////////////////////////////////////////////////////
472
  ///////////////////////////// SLICERS //////////////////////////////
473
  ////////////////////////////////////////////////////////////////////
474
475
  /**
476
   * Get the first value from an array.
477
   *
478
   * @param int|null $take
479
   *
480
   * @return self
481
   */
482 27
  public function first($take = null)
483
  {
484 27
    if ($take === null) {
485 13
      $array = array_shift($this->array);
486 13
    } else {
487 14
      $array = array_splice($this->array, 0, $take, true);
488
    }
489
490 27
    return self::create((array)$array);
491
  }
492
493
  /**
494
   * Get the last value from an array.
495
   *
496
   * @param int|null $take
497
   *
498
   * @return self
499
   */
500 10
  public function last($take = null)
501
  {
502 10
    if ($take === null) {
503 7
      $array = self::create((array)array_pop($this->array));
504 7
    } else {
505 3
      $array = $this->rest(-$take);
506
    }
507
508 10
    return $array;
509
  }
510
511
  /**
512
   * Get everything but the last..$to items.
513
   *
514
   * @param int $to
515
   *
516
   * @return self
517
   */
518 10
  public function initial($to = 1)
519
  {
520 10
    $slice = count($this->array) - $to;
521
522 10
    return $this->first($slice);
523
  }
524
525
  /**
526
   * Get the last elements from index $from.
527
   *
528
   * @param int $from
529
   *
530
   * @return self
531
   */
532 13
  public function rest($from = 1)
533
  {
534 13
    return self::create(array_splice($this->array, $from));
535
  }
536
537
  ////////////////////////////////////////////////////////////////////
538
  ///////////////////////////// ACT UPON /////////////////////////////
539
  ////////////////////////////////////////////////////////////////////
540
541
  /**
542
   * Iterate over an array and execute a callback for each loop.
543
   *
544
   * @param \Closure $closure
545
   *
546
   * @return mixed
547
   */
548 1 View Code Duplication
  public function at(\Closure $closure)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
549
  {
550 1
    $array = $this->array;
551
552 1
    foreach ($array as $key => $value) {
553 1
      $closure($value, $key);
554 1
    }
555
556 1
    return self::create($array);
557
  }
558
559
  ////////////////////////////////////////////////////////////////////
560
  ////////////////////////////// ALTER ///////////////////////////////
561
  ////////////////////////////////////////////////////////////////////
562
563
  /**
564
   * Merge the new $array into the current array, replace already existing keys
565
   * from the current array with the key,values from the new $array
566
   * and create new indexes.
567
   *
568
   * @param array $array
569
   *
570
   * @return self
571
   */
572 8
  public function mergeAppendNewIndex(array $array = array())
573
  {
574 8
    return self::create(array_merge($this->array, $array));
575
  }
576
577
  /**
578
   * Merge the current array into the new $array, replace already existing keys
579
   * from new $array with the key,values from the current array
580
   * and create new indexes.
581
   *
582
   * @param array $array
583
   *
584
   * @return self
585
   */
586
  public function mergePrependNewIndex(array $array = array())
587
  {
588
    return self::create(array_merge($array, $this->array));
589
  }
590
591
  /**
592
   * Merge the new $array into the current array and
593
   * keep keys and values from the current array.
594
   *
595
   * @param array $array
596
   *
597
   * @return self
598
   */
599
  public function mergeAppendKeepIndex(array $array = array())
600
  {
601
    /** @noinspection AdditionOperationOnArraysInspection */
602
    return self::create($this->array + $array);
603
  }
604
605
  /**
606
   * Merge the the current array into the $array, keep keys and values from the new $array.
607
   *
608
   * @param array $array
609
   *
610
   * @return self
611
   */
612
  public function mergePrependKeepIndex(array $array = array())
613
  {
614
    /** @noinspection AdditionOperationOnArraysInspection */
615
    return self::create($array + $this->array);
616
  }
617
618
  /**
619
   * Merge the new $array into the current array, keep keys from the current array
620
   * and overwrite values with the new $array.
621
   *
622
   * @param $array
623
   *
624
   * @return self
625
   */
626
  public function mergeReplaceAppend(array $array = array())
627
  {
628
    return self::create(array_replace($this->array, $array));
629
  }
630
631
  /**
632
   * Merge the the current array into the $array, keep keys from the new $array
633
   * and overwrite values with the old from the current array.
634
   *
635
   * @param $array
636
   *
637
   * @return self
638
   */
639
  public function mergeReplacePrepend(array $array = array())
640
  {
641
    return self::create(array_replace($array, $this->array));
642
  }
643
644
  /**
645
   * Return values that are only in the current array.
646
   *
647
   * @param array $array
648
   *
649
   * @return self
650
   */
651
  public function diff(array $array = array())
652
  {
653
    return self::create(array_diff($this->array, $array));
654
  }
655
656
  /**
657
   * Return values that are only in the new $array.
658
   *
659
   * @param array $array
660
   *
661
   * @return self
662
   */
663
  public function diffReverse(array $array = array())
664
  {
665
    return self::create(array_diff($array, $this->array));
666
  }
667
668
  /**
669
   * Replace a value in an array.
670
   *
671
   * @param string $replace The string to replace
672
   * @param string $with    What to replace it with
673
   *
674
   * @return self
675
   */
676 3
  public function replaceValue($replace, $with = '')
677
  {
678 3
    $array = $this->each(
679
        function ($value) use ($replace, $with) {
680 3
          return UTF8::str_replace($replace, $with, $value);
681
        }
682 3
    );
683
684 3
    return self::create((array)$array);
685
  }
686
687
  /**
688
   * Replace the keys in an array with another set.
689
   *
690
   * @param array $keys An array of keys matching the array's size
691
   *
692
   * @return self
693
   */
694 1
  public function replaceKeys(array $keys)
695
  {
696 1
    $values = array_values($this->array);
697
698 1
    return self::create(array_combine($keys, $values));
699
  }
700
701
  /**
702
   * Iterate over an array and modify the array's value.
703
   *
704
   * @param \Closure $closure
705
   *
706
   * @return array
707
   */
708 20 View Code Duplication
  public function each(\Closure $closure)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
709
  {
710 20
    $array = $this->array;
711
712 20
    foreach ($array as $key => &$value) {
713 16
      $value = $closure($value, $key);
714 20
    }
715
716 20
    return $array;
717
  }
718
719
  /**
720
   * Shuffle an array.
721
   *
722
   * @return self
723
   */
724 1
  public function shuffle()
725
  {
726 1
    $array = $this->array;
727
728 1
    shuffle($array);
729
730 1
    return self::create($array);
731
  }
732
733
  /**
734
   * Sort an array by key.
735
   *
736
   * @param string $direction
737
   *
738
   * @return self
739
   */
740 8
  public function sortKeys($direction = 'ASC')
741
  {
742 8
    $array = $this->array;
743 8
    $direction = strtolower($direction);
744
745 8
    if ($direction === 'desc') {
746 1
      $directionType = SORT_DESC;
747 1
    } else {
748 7
      $directionType = SORT_ASC;
749
    }
750
751 8
    if ($directionType === SORT_ASC) {
752 7
      ksort($array);
753 7
    } else {
754 1
      krsort($array);
755
    }
756
757 8
    return self::create($array);
758
  }
759
760
  /**
761
   * Implodes an array.
762
   *
763
   * @param string $with What to implode it with
764
   *
765
   * @return string
766
   */
767 21
  public function implode($with = '')
768
  {
769 21
    return implode($with, $this->array);
770
  }
771
772
  /**
773
   * Find all items in an array that pass the truth test.
774
   *
775
   * @param null $closure
776
   *
777
   * @return self
778
   */
779 8
  public function filter($closure = null)
780
  {
781 8
    if (!$closure) {
782
      return $this->clean();
783
    }
784
785 8
    $array = array_filter($this->array, $closure);
786
787 8
    return self::create($array);
788
  }
789
790
  /**
791
   * Invoke a function on all of an array's values.
792
   *
793
   * @param mixed $callable
794
   * @param array $arguments
795
   *
796
   * @return self
797
   */
798 1
  public function invoke($callable, $arguments = array())
799
  {
800
    // If one argument given for each iteration, create an array for it.
801 1
    if (!is_array($arguments)) {
802 1
      $arguments = StaticArrayy::repeat($arguments, count($this->array))->getArray();
803 1
    }
804
805
    // If the callable has arguments, pass them.
806 1
    if ($arguments) {
0 ignored issues
show
Bug Best Practice introduced by
The expression $arguments of type array is implicitly converted to a boolean; are you sure this is intended? If so, consider using ! empty($expr) instead to make it clear that you intend to check for an array without elements.

This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent.

Consider making the comparison explicit by using empty(..) or ! empty(...) instead.

Loading history...
807 1
      $array = array_map($callable, $this->array, $arguments);
808 1
    } else {
809 1
      $array = array_map($callable, $this->array);
810
    }
811
812 1
    return self::create($array);
813
  }
814
815
  /**
816
   * Return all items that fail the truth test.
817
   *
818
   * @param \Closure $closure
819
   *
820
   * @return self
821
   */
822 1 View Code Duplication
  public function reject(\Closure $closure)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
823
  {
824 1
    $filtered = array();
825
826 1
    foreach ($this->array as $key => $value) {
827 1
      if (!$closure($value, $key)) {
828 1
        $filtered[$key] = $value;
829 1
      }
830 1
    }
831
832 1
    return self::create($filtered);
833
  }
834
835
  /**
836
   * Remove the first value from an array.
837
   *
838
   * @return self
839
   */
840 8
  public function removeFirst()
841
  {
842 8
    array_shift($this->array);
843
844 8
    return self::create($this->array);
845
  }
846
847
  /**
848
   * Remove the last value from an array.
849
   *
850
   * @return self
851
   */
852 7
  public function removeLast()
853
  {
854 7
    array_pop($this->array);
855
856 7
    return self::create($this->array);
857
  }
858
859
  /**
860
   * Removes a particular value from an array (numeric or associative).
861
   *
862
   * @param mixed $value
863
   *
864
   * @return self
865
   */
866 7
  public function removeValue($value)
867
  {
868 7
    $isNumericArray = true;
869 7
    foreach ($this->array as $key => $item) {
870 6
      if ($item === $value) {
871 6
        if (!is_int($key)) {
872
          $isNumericArray = false;
873
        }
874 6
        unset($this->array[$key]);
875 6
      }
876 7
    }
877
878 7
    if ($isNumericArray) {
879 7
      $this->array = array_values($this->array);
880 7
    }
881
882 7
    return self::create($this->array);
883
  }
884
885
  /**
886
   * Prepend a value to an array.
887
   *
888
   * @param mixed $value
889
   *
890
   * @return self
891
   */
892 7
  public function prepend($value)
893
  {
894 7
    array_unshift($this->array, $value);
895
896 7
    return self::create($this->array);
897
  }
898
899
  /**
900
   * Append a value to an array.
901
   *
902
   * @param mixed $value
903
   *
904
   * @return self
905
   */
906 8
  public function append($value)
907
  {
908 8
    $this->array[] = $value;
909
910 8
    return self::create($this->array);
911
  }
912
913
  /**
914
   * Return the array in the reverse order.
915
   *
916
   * @return self
917
   */
918 7
  public function reverse()
919
  {
920 7
    $this->array = array_reverse($this->array);
921
922 7
    return self::create($this->array);
923
  }
924
925
  /**
926
   * duplicate free copy of an array
927
   *
928
   * @return self
929
   */
930 7
  public function unique()
931
  {
932 7
    $this->array = array_reduce(
0 ignored issues
show
Documentation Bug introduced by
It seems like array_reduce($this->arra...esultArray; }, array()) of type * is incompatible with the declared type array of property $array.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
933 7
        $this->array,
934 7
        function ($resultArray, $value) {
935 6
          if (in_array($value, $resultArray, true) === false) {
936 6
            $resultArray[] = $value;
937 6
          }
938
939 6
          return $resultArray;
940 7
        },
941 7
        array()
942 7
    );
943
944 7
    return self::create($this->array);
945
  }
946
}
947