Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.
Common duplication problems, and corresponding solutions are:
Complex classes like Arrayy often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use Arrayy, and based on these observations, apply Extract Interface, too.
| 1 | <?php |
||
| 13 | class Arrayy extends \ArrayObject implements \ArrayAccess, \Serializable, \Countable |
||
| 14 | { |
||
| 15 | /** |
||
| 16 | * @var array |
||
| 17 | */ |
||
| 18 | protected $array = array(); |
||
| 19 | |||
| 20 | /** |
||
| 21 | * @var string |
||
| 22 | */ |
||
| 23 | protected $pathSeparator = '.'; |
||
| 24 | |||
| 25 | /** @noinspection MagicMethodsValidityInspection */ |
||
| 26 | /** |
||
| 27 | * Initializes |
||
| 28 | * |
||
| 29 | * @param array $array |
||
| 30 | */ |
||
| 31 | 759 | public function __construct($array = array()) |
|
| 37 | |||
| 38 | /** |
||
| 39 | * Get a value by key. |
||
| 40 | * |
||
| 41 | * @param $key |
||
| 42 | * |
||
| 43 | * @return mixed <p>Get a Value from the current array.</p> |
||
| 44 | */ |
||
| 45 | 1 | public function __get($key) |
|
| 55 | |||
| 56 | /** |
||
| 57 | * Call object as function. |
||
| 58 | * |
||
| 59 | * @param mixed $key |
||
| 60 | * |
||
| 61 | * @return mixed |
||
| 62 | */ |
||
| 63 | public function __invoke($key = null) |
||
| 75 | |||
| 76 | /** |
||
| 77 | * Whether or not an element exists by key. |
||
| 78 | * |
||
| 79 | * @param mixed $key |
||
| 80 | * |
||
| 81 | * @return bool <p>True is the key/index exists, otherwise false.</p> |
||
| 82 | */ |
||
| 83 | public function __isset($key) |
||
| 87 | |||
| 88 | /** |
||
| 89 | * Assigns a value to the specified element. |
||
| 90 | * |
||
| 91 | * @param mixed $key |
||
| 92 | * @param mixed $value |
||
| 93 | */ |
||
| 94 | 2 | public function __set($key, $value) |
|
| 98 | |||
| 99 | /** |
||
| 100 | * magic to string |
||
| 101 | * |
||
| 102 | * @return string |
||
| 103 | */ |
||
| 104 | 16 | public function __toString() |
|
| 108 | |||
| 109 | /** |
||
| 110 | * Unset element by key. |
||
| 111 | * |
||
| 112 | * @param mixed $key |
||
| 113 | */ |
||
| 114 | public function __unset($key) |
||
| 118 | |||
| 119 | /** |
||
| 120 | * alias: for "Arrayy->append()" |
||
| 121 | * |
||
| 122 | * @see Arrayy::append() |
||
| 123 | * |
||
| 124 | * @param mixed $value |
||
| 125 | * |
||
| 126 | * @return static <p>(Mutable) Return this Arrayy object, with the appended values.</p> |
||
| 127 | */ |
||
| 128 | 1 | public function add($value) |
|
| 132 | |||
| 133 | /** |
||
| 134 | * Append a value to the current array. |
||
| 135 | * |
||
| 136 | * @param mixed $value |
||
| 137 | * |
||
| 138 | * @return static <p>(Mutable) Return this Arrayy object, with the appended values.</p> |
||
| 139 | */ |
||
| 140 | 9 | public function append($value) |
|
| 146 | |||
| 147 | /** |
||
| 148 | * Count the values from the current array. |
||
| 149 | * |
||
| 150 | * alias: for "Arrayy->size()" |
||
| 151 | * |
||
| 152 | * @see Arrayy::size() |
||
| 153 | * |
||
| 154 | * @return int |
||
| 155 | */ |
||
| 156 | 93 | public function count() |
|
| 160 | |||
| 161 | /** |
||
| 162 | * Returns a new ArrayyIterator, thus implementing the IteratorAggregate interface. |
||
| 163 | * |
||
| 164 | * @return ArrayyIterator <p>An iterator for the values in the array.</p> |
||
| 165 | */ |
||
| 166 | 19 | public function getIterator() |
|
| 170 | |||
| 171 | /** |
||
| 172 | * Whether or not an offset exists. |
||
| 173 | * |
||
| 174 | * @param int|float|string $offset |
||
| 175 | * |
||
| 176 | * @return bool |
||
| 177 | */ |
||
| 178 | 38 | public function offsetExists($offset) |
|
| 222 | |||
| 223 | /** |
||
| 224 | * Returns the value at specified offset. |
||
| 225 | * |
||
| 226 | * @param mixed $offset |
||
| 227 | * |
||
| 228 | * @return mixed <p>Will return null if the offset did not exists.</p> |
||
| 229 | */ |
||
| 230 | 24 | public function offsetGet($offset) |
|
| 234 | |||
| 235 | /** |
||
| 236 | * Assigns a value to the specified offset. |
||
| 237 | * |
||
| 238 | * @param mixed $offset |
||
| 239 | * @param mixed $value |
||
| 240 | */ |
||
| 241 | 15 | public function offsetSet($offset, $value) |
|
| 249 | |||
| 250 | /** |
||
| 251 | * Unset an offset. |
||
| 252 | * |
||
| 253 | * @param mixed $offset |
||
| 254 | */ |
||
| 255 | 6 | public function offsetUnset($offset) |
|
| 281 | |||
| 282 | /** |
||
| 283 | * Changes all keys in an array. |
||
| 284 | * |
||
| 285 | * @param int $case [optional] <p> Either <strong>CASE_UPPER</strong><br /> |
||
| 286 | * or <strong>CASE_LOWER</strong> (default)</p> |
||
| 287 | 2 | * |
|
| 288 | * @return static <p>(Immutable)</p> |
||
| 289 | 2 | */ |
|
| 290 | public function changeKeyCase($case = CASE_LOWER) |
||
| 294 | |||
| 295 | /** |
||
| 296 | * Serialize the current array. |
||
| 297 | * |
||
| 298 | * @return string |
||
| 299 | 2 | */ |
|
| 300 | public function serialize() |
||
| 304 | |||
| 305 | /** |
||
| 306 | * Unserialize an string and return this object. |
||
| 307 | * |
||
| 308 | * @param string $string |
||
| 309 | * |
||
| 310 | * @return static <p>(Mutable)</p> |
||
| 311 | */ |
||
| 312 | public function unserialize($string) |
||
| 318 | 2 | ||
| 319 | 2 | /** |
|
| 320 | * Iterate over the current array and execute a callback for each loop. |
||
| 321 | 2 | * |
|
| 322 | * @param \Closure $closure |
||
| 323 | * |
||
| 324 | * @return static <p>(Immutable)</p> |
||
| 325 | */ |
||
| 326 | View Code Duplication | public function at(\Closure $closure) |
|
| 336 | 2 | ||
| 337 | /** |
||
| 338 | * Returns the average value of the current array. |
||
| 339 | 8 | * |
|
| 340 | 3 | * @param int $decimals <p>The number of decimal-numbers to return.</p> |
|
| 341 | 3 | * |
|
| 342 | * @return int|double <p>The average value.</p> |
||
| 343 | 8 | */ |
|
| 344 | public function average($decimals = 0) |
||
| 358 | 2 | ||
| 359 | /** |
||
| 360 | 2 | * @param mixed $path |
|
| 361 | * @param callable $callable |
||
| 362 | * @param null|array $currentOffset |
||
| 363 | */ |
||
| 364 | 2 | protected function callAtPath($path, $callable, &$currentOffset = null) |
|
| 387 | |||
| 388 | /** |
||
| 389 | * Change the path separator of the array wrapper. |
||
| 390 | * |
||
| 391 | * By default, the separator is: "." |
||
| 392 | * |
||
| 393 | * @param string $separator <p>Separator to set.</p> |
||
| 394 | * |
||
| 395 | * @return static <p>Mutable</p> |
||
| 396 | */ |
||
| 397 | public function changeSeparator($separator) |
||
| 403 | 4 | ||
| 404 | /** |
||
| 405 | * Create a chunked version of the current array. |
||
| 406 | * |
||
| 407 | * @param int $size <p>Size of each chunk.</p> |
||
| 408 | * @param bool $preserveKeys <p>Whether array keys are preserved or no.</p> |
||
| 409 | * |
||
| 410 | * @return static <p>(Immutable) A new array of chunks from the original array.</p> |
||
| 411 | 8 | */ |
|
| 412 | public function chunk($size, $preserveKeys = false) |
||
| 418 | |||
| 419 | /** |
||
| 420 | * Clean all falsy values from the current array. |
||
| 421 | * |
||
| 422 | * @return static <p>(Immutable)</p> |
||
| 423 | */ |
||
| 424 | public function clean() |
||
| 432 | |||
| 433 | /** |
||
| 434 | * WARNING!!! -> Clear the current array. |
||
| 435 | * |
||
| 436 | * @return static <p>(Mutable) Return this Arrayy object, with an empty array.</p> |
||
| 437 | */ |
||
| 438 | public function clear() |
||
| 444 | |||
| 445 | /** |
||
| 446 | * Check if an item is in the current array. |
||
| 447 | * |
||
| 448 | * @param string|int|float $value |
||
| 449 | * |
||
| 450 | * @return bool |
||
| 451 | 13 | */ |
|
| 452 | public function contains($value) |
||
| 456 | |||
| 457 | 13 | /** |
|
| 458 | 13 | * Check if an (case-insensitive) string is in the current array. |
|
| 459 | 13 | * |
|
| 460 | 13 | * @param string $value |
|
| 461 | 13 | * |
|
| 462 | * @return bool |
||
| 463 | 13 | */ |
|
| 464 | public function containsCaseInsensitive($value) |
||
| 478 | |||
| 479 | /** |
||
| 480 | * Check if the given key/index exists in the array. |
||
| 481 | * |
||
| 482 | * @param string|int|float $key <p>key/index to search for</p> |
||
| 483 | * |
||
| 484 | * @return bool <p>Returns true if the given key/index exists in the array, false otherwise.</p> |
||
| 485 | 1 | */ |
|
| 486 | public function containsKey($key) |
||
| 490 | |||
| 491 | /** |
||
| 492 | * Check if all given needles are present in the array as key/index. |
||
| 493 | * |
||
| 494 | * @param array $needles |
||
| 495 | * |
||
| 496 | * @return bool <p>Returns true if the given keys/indexes exists in the array, false otherwise.</p> |
||
| 497 | */ |
||
| 498 | public function containsKeys(array $needles) |
||
| 502 | |||
| 503 | /** |
||
| 504 | * alias: for "Arrayy->contains()" |
||
| 505 | * |
||
| 506 | * @see Arrayy::contains() |
||
| 507 | * |
||
| 508 | * @param string|int|float $value |
||
| 509 | * |
||
| 510 | * @return bool |
||
| 511 | 1 | */ |
|
| 512 | public function containsValue($value) |
||
| 516 | |||
| 517 | /** |
||
| 518 | * Check if all given needles are present in the array. |
||
| 519 | * |
||
| 520 | * @param array $needles |
||
| 521 | * |
||
| 522 | * @return bool <p>Returns true if the given values exists in the array, false otherwise.</p> |
||
| 523 | 479 | */ |
|
| 524 | public function containsValues(array $needles) |
||
| 528 | |||
| 529 | /** |
||
| 530 | * Creates an Arrayy object. |
||
| 531 | * |
||
| 532 | * @param array $array |
||
| 533 | * |
||
| 534 | * @return static <p>(Immutable) Returns an new instance of the Arrayy object.</p> |
||
| 535 | 1 | */ |
|
| 536 | public static function create($array = array()) |
||
| 540 | |||
| 541 | 1 | /** |
|
| 542 | * Generate array of repeated arrays. |
||
| 543 | * |
||
| 544 | * @param int $times <p>How many times has to be repeated.</p> |
||
| 545 | * |
||
| 546 | * @return Arrayy |
||
| 547 | */ |
||
| 548 | public function repeat($times) |
||
| 556 | |||
| 557 | |||
| 558 | /** |
||
| 559 | * WARNING: Creates an Arrayy object by reference. |
||
| 560 | * |
||
| 561 | * @param array $array |
||
| 562 | * |
||
| 563 | * @return static <p>(Mutable) Return this Arrayy object.</p> |
||
| 564 | */ |
||
| 565 | public function createByReference(&$array = array()) |
||
| 573 | |||
| 574 | /** |
||
| 575 | * Create an new Arrayy object via JSON. |
||
| 576 | * |
||
| 577 | * @param string $json |
||
| 578 | * |
||
| 579 | * @return static <p>(Immutable) Returns an new instance of the Arrayy object.</p> |
||
| 580 | */ |
||
| 581 | public static function createFromJson($json) |
||
| 587 | 3 | ||
| 588 | 4 | /** |
|
| 589 | * Create an new instance filled with values from an object that have implemented ArrayAccess. |
||
| 590 | 4 | * |
|
| 591 | * @param \ArrayAccess $object <p>Object that implements ArrayAccess</p> |
||
| 592 | * |
||
| 593 | * @return static <p>(Immutable) Returns an new instance of the Arrayy object.</p> |
||
| 594 | */ |
||
| 595 | public static function createFromObject(\ArrayAccess $object) |
||
| 605 | 8 | ||
| 606 | 1 | /** |
|
| 607 | * Create an new Arrayy object via string. |
||
| 608 | 1 | * |
|
| 609 | 1 | * @param string $str <p>The input string.</p> |
|
| 610 | 1 | * @param string|null $delimiter <p>The boundary string.</p> |
|
| 611 | * @param string|null $regEx <p>Use the $delimiter or the $regEx, so if $pattern is null, $delimiter will be |
||
| 612 | 1 | * used.</p> |
|
| 613 | 7 | * |
|
| 614 | * @return static <p>(Immutable) Returns an new instance of the Arrayy object.</p> |
||
| 615 | */ |
||
| 616 | public static function createFromString($str, $delimiter, $regEx = null) |
||
| 642 | |||
| 643 | /** |
||
| 644 | * Create an new instance containing a range of elements. |
||
| 645 | * |
||
| 646 | * @param mixed $low <p>First value of the sequence.</p> |
||
| 647 | * @param mixed $high <p>The sequence is ended upon reaching the end value.</p> |
||
| 648 | * @param int $step <p>Used as the increment between elements in the sequence.</p> |
||
| 649 | * |
||
| 650 | * @return static <p>(Immutable) Returns an new instance of the Arrayy object.</p> |
||
| 651 | */ |
||
| 652 | public static function createWithRange($low, $high, $step = 1) |
||
| 656 | |||
| 657 | 5 | /** |
|
| 658 | * Custom sort by index via "uksort". |
||
| 659 | * |
||
| 660 | * @link http://php.net/manual/en/function.uksort.php |
||
| 661 | * |
||
| 662 | * @param callable $function |
||
| 663 | * |
||
| 664 | * @return static <p>(Mutable) Return this Arrayy object.</p> |
||
| 665 | */ |
||
| 666 | public function customSortKeys($function) |
||
| 672 | |||
| 673 | 4 | /** |
|
| 674 | * Custom sort by value via "usort". |
||
| 675 | * |
||
| 676 | * @link http://php.net/manual/en/function.usort.php |
||
| 677 | * |
||
| 678 | * @param callable $function |
||
| 679 | * |
||
| 680 | * @return static <p>(Mutable) Return this Arrayy object.</p> |
||
| 681 | */ |
||
| 682 | public function customSortValues($function) |
||
| 688 | |||
| 689 | /** |
||
| 690 | * Return values that are only in the current array. |
||
| 691 | * |
||
| 692 | * @param array $array |
||
| 693 | * |
||
| 694 | * @return static <p>(Immutable)</p> |
||
| 695 | */ |
||
| 696 | public function diff(array $array = array()) |
||
| 702 | |||
| 703 | /** |
||
| 704 | 1 | * Return values that are only in the current multi-dimensional array. |
|
| 705 | 1 | * |
|
| 706 | 1 | * @param array $array |
|
| 707 | 1 | * @param null|array $helperVariableForRecursion <p>(only for internal usage)</p> |
|
| 708 | 1 | * |
|
| 709 | 1 | * @return static <p>(Immutable)</p> |
|
| 710 | */ |
||
| 711 | public function diffRecursive(array $array = array(), $helperVariableForRecursion = null) |
||
| 744 | |||
| 745 | /** |
||
| 746 | * Return values that are only in the new $array. |
||
| 747 | * |
||
| 748 | * @param array $array |
||
| 749 | * |
||
| 750 | * @return static <p>(Immutable)</p> |
||
| 751 | 1 | */ |
|
| 752 | public function diffReverse(array $array = array()) |
||
| 758 | 1 | ||
| 759 | /** |
||
| 760 | * Divide an array into two arrays. One with keys and the other with values. |
||
| 761 | * |
||
| 762 | * @return static <p>(Immutable)</p> |
||
| 763 | */ |
||
| 764 | public function divide() |
||
| 773 | 4 | ||
| 774 | 4 | /** |
|
| 775 | * Iterate over the current array and modify the array's value. |
||
| 776 | 4 | * |
|
| 777 | * @param \Closure $closure |
||
| 778 | * |
||
| 779 | * @return static <p>(Immutable)</p> |
||
| 780 | */ |
||
| 781 | View Code Duplication | public function each(\Closure $closure) |
|
| 791 | 1 | ||
| 792 | 1 | /** |
|
| 793 | * Check if a value is in the current array using a closure. |
||
| 794 | 4 | * |
|
| 795 | * @param \Closure $closure |
||
| 796 | 4 | * |
|
| 797 | * @return bool <p>Returns true if the given value is found, false otherwise.</p> |
||
| 798 | */ |
||
| 799 | public function exists(\Closure $closure) |
||
| 811 | |||
| 812 | /** |
||
| 813 | * create a fallback for array |
||
| 814 | * |
||
| 815 | * 1. use the current array, if it's a array |
||
| 816 | 759 | * 2. call "getArray()" on object, if there is a "Arrayy"-object |
|
| 817 | * 3. fallback to empty array, if there is nothing |
||
| 818 | 759 | * 4. call "createFromObject()" on object, if there is a "\ArrayAccess"-object |
|
| 819 | 756 | * 5. call "__toArray()" on object, if the method exists |
|
| 820 | * 6. cast a string or object with "__toString()" into an array |
||
| 821 | * 7. throw a "InvalidArgumentException"-Exception |
||
| 822 | 10 | * |
|
| 823 | 1 | * @param $array |
|
| 824 | * |
||
| 825 | * @return array |
||
| 826 | 9 | * |
|
| 827 | 6 | * @throws \InvalidArgumentException |
|
| 828 | */ |
||
| 829 | protected function fallbackForArray(&$array) |
||
| 865 | |||
| 866 | 9 | /** |
|
| 867 | * Find all items in an array that pass the truth test. |
||
| 868 | 9 | * |
|
| 869 | * @param \Closure|null $closure |
||
| 870 | * |
||
| 871 | * @return static <p>(Immutable)</p> |
||
| 872 | */ |
||
| 873 | public function filter($closure = null) |
||
| 883 | |||
| 884 | /** |
||
| 885 | * Filters an array of objects (or a numeric array of associative arrays) based on the value of a particular property |
||
| 886 | * within that. |
||
| 887 | * |
||
| 888 | * @param string $property |
||
| 889 | * @param string $value |
||
| 890 | * @param string $comparisonOp |
||
| 891 | * <p> |
||
| 892 | * 'eq' (equals),<br /> |
||
| 893 | 1 | * 'gt' (greater),<br /> |
|
| 894 | * 'gte' || 'ge' (greater or equals),<br /> |
||
| 895 | 1 | * 'lt' (less),<br /> |
|
| 896 | 1 | * 'lte' || 'le' (less or equals),<br /> |
|
| 897 | 1 | * 'ne' (not equals),<br /> |
|
| 898 | * 'contains',<br /> |
||
| 899 | * 'notContains',<br /> |
||
| 900 | * 'newer' (via strtotime),<br /> |
||
| 901 | 1 | * 'older' (via strtotime),<br /> |
|
| 902 | 1 | * </p> |
|
| 903 | * |
||
| 904 | * @return static <p>(Immutable)</p> |
||
| 905 | 1 | */ |
|
| 906 | public function filterBy($property, $value, $comparisonOp = null) |
||
| 971 | 5 | ||
| 972 | /** |
||
| 973 | 5 | * Find the first item in an array that passes the truth test, |
|
| 974 | * otherwise return false |
||
| 975 | 3 | * |
|
| 976 | * @param \Closure $closure |
||
| 977 | * |
||
| 978 | * @return mixed|false <p>Return false if we did not find the value.</p> |
||
| 979 | */ |
||
| 980 | public function find(\Closure $closure) |
||
| 990 | |||
| 991 | /** |
||
| 992 | * find by ... |
||
| 993 | * |
||
| 994 | * @param string $property |
||
| 995 | * @param string $value |
||
| 996 | * @param string $comparisonOp |
||
| 997 | 13 | * |
|
| 998 | * @return static <p>(Immutable)</p> |
||
| 999 | 13 | */ |
|
| 1000 | 13 | public function findBy($property, $value, $comparisonOp = 'eq') |
|
| 1004 | |||
| 1005 | /** |
||
| 1006 | 10 | * Get the first value from the current array. |
|
| 1007 | * |
||
| 1008 | * @return mixed <p>Return null if there wasn't a element.</p> |
||
| 1009 | */ |
||
| 1010 | public function first() |
||
| 1021 | 7 | ||
| 1022 | 21 | /** |
|
| 1023 | 21 | * Get the first value(s) from the current array. |
|
| 1024 | 21 | * |
|
| 1025 | * @param int|null $number <p>How many values you will take?</p> |
||
| 1026 | * |
||
| 1027 | 28 | * @return static <p>(Immutable)</p> |
|
| 1028 | */ |
||
| 1029 | public function firstsImmutable($number = null) |
||
| 1042 | 15 | ||
| 1043 | 15 | /** |
|
| 1044 | * Get the first value(s) from the current array. |
||
| 1045 | * |
||
| 1046 | 26 | * @param int|null $number <p>How many values you will take?</p> |
|
| 1047 | * |
||
| 1048 | * @return static <p>(Mutable)</p> |
||
| 1049 | */ |
||
| 1050 | public function firstsMutable($number = null) |
||
| 1061 | |||
| 1062 | /** |
||
| 1063 | * Exchanges all keys with their associated values in an array. |
||
| 1064 | * |
||
| 1065 | * @return static <p>(Immutable)</p> |
||
| 1066 | */ |
||
| 1067 | public function flip() |
||
| 1073 | |||
| 1074 | /** |
||
| 1075 | 58 | * Get a value from an array (optional using dot-notation). |
|
| 1076 | 3 | * |
|
| 1077 | 58 | * @param string $key <p>The key to look for.</p> |
|
| 1078 | 3 | * @param mixed $fallback <p>Value to fallback to.</p> |
|
| 1079 | 3 | * @param array $array <p>The array to get from, if it's set to "null" we use the current array from the |
|
| 1080 | 56 | * class.</p> |
|
| 1081 | * |
||
| 1082 | * @return mixed |
||
| 1083 | 58 | */ |
|
| 1084 | 1 | public function get($key, $fallback = null, $array = null) |
|
| 1128 | |||
| 1129 | /** |
||
| 1130 | * Get the current array from the "Arrayy"-object. |
||
| 1131 | 399 | * |
|
| 1132 | * @return array |
||
| 1133 | 399 | */ |
|
| 1134 | public function getArray() |
||
| 1140 | |||
| 1141 | /** |
||
| 1142 | * @param mixed $value |
||
| 1143 | */ |
||
| 1144 | protected function internalGetArray(&$value) |
||
| 1150 | 1 | ||
| 1151 | /** |
||
| 1152 | 1 | * Returns the values from a single column of the input array, identified by |
|
| 1153 | * the $columnKey, can be used to extract data-columns from multi-arrays. |
||
| 1154 | 1 | * |
|
| 1155 | * Info: Optionally, you may provide an $indexKey to index the values in the returned |
||
| 1156 | * array by the values from the $indexKey column in the input array. |
||
| 1157 | * |
||
| 1158 | * @param mixed $columnKey |
||
| 1159 | * @param mixed $indexKey |
||
| 1160 | * |
||
| 1161 | * @return static <p>(Immutable)</p> |
||
| 1162 | */ |
||
| 1163 | public function getColumn($columnKey = null, $indexKey = null) |
||
| 1169 | 10 | ||
| 1170 | 2 | /** |
|
| 1171 | 2 | * Get correct PHP constant for direction. |
|
| 1172 | 8 | * |
|
| 1173 | * @param int|string $direction |
||
| 1174 | 10 | * |
|
| 1175 | * @return int |
||
| 1176 | */ |
||
| 1177 | protected function getDirection($direction) |
||
| 1199 | |||
| 1200 | /** |
||
| 1201 | * alias: for "Arrayy->keys()" |
||
| 1202 | * |
||
| 1203 | * @see Arrayy::keys() |
||
| 1204 | * |
||
| 1205 | * @return static <p>(Immutable)</p> |
||
| 1206 | 3 | */ |
|
| 1207 | public function getKeys() |
||
| 1211 | |||
| 1212 | /** |
||
| 1213 | * alias: for "Arrayy->randomImmutable()" |
||
| 1214 | * |
||
| 1215 | * @see Arrayy::randomImmutable() |
||
| 1216 | * |
||
| 1217 | * @return static <p>(Immutable)</p> |
||
| 1218 | 3 | */ |
|
| 1219 | public function getRandom() |
||
| 1223 | |||
| 1224 | /** |
||
| 1225 | * alias: for "Arrayy->randomKey()" |
||
| 1226 | * |
||
| 1227 | * @see Arrayy::randomKey() |
||
| 1228 | * |
||
| 1229 | * @return mixed <p>Get a key/index or null if there wasn't a key/index.</p> |
||
| 1230 | */ |
||
| 1231 | public function getRandomKey() |
||
| 1235 | |||
| 1236 | /** |
||
| 1237 | * alias: for "Arrayy->randomKeys()" |
||
| 1238 | * |
||
| 1239 | * @see Arrayy::randomKeys() |
||
| 1240 | * |
||
| 1241 | * @param int $number |
||
| 1242 | * |
||
| 1243 | * @return static <p>(Immutable)</p> |
||
| 1244 | 3 | */ |
|
| 1245 | public function getRandomKeys($number) |
||
| 1249 | |||
| 1250 | /** |
||
| 1251 | * alias: for "Arrayy->randomValue()" |
||
| 1252 | * |
||
| 1253 | * @see Arrayy::randomValue() |
||
| 1254 | * |
||
| 1255 | * @return mixed <p>get a random value or null if there wasn't a value.</p> |
||
| 1256 | */ |
||
| 1257 | public function getRandomValue() |
||
| 1261 | |||
| 1262 | /** |
||
| 1263 | * alias: for "Arrayy->randomValues()" |
||
| 1264 | * |
||
| 1265 | * @see Arrayy::randomValues() |
||
| 1266 | * |
||
| 1267 | * @param int $number |
||
| 1268 | * |
||
| 1269 | * @return static <p>(Immutable)</p> |
||
| 1270 | */ |
||
| 1271 | 3 | public function getRandomValues($number) |
|
| 1275 | |||
| 1276 | /** |
||
| 1277 | 3 | * Group values from a array according to the results of a closure. |
|
| 1278 | * |
||
| 1279 | 3 | * @param string $grouper <p>A callable function name.</p> |
|
| 1280 | 3 | * @param bool $saveKeys |
|
| 1281 | * |
||
| 1282 | 3 | * @return static <p>(Immutable)</p> |
|
| 1283 | */ |
||
| 1284 | public function group($grouper, $saveKeys = false) |
||
| 1318 | 22 | ||
| 1319 | /** |
||
| 1320 | * Check if an array has a given key. |
||
| 1321 | * |
||
| 1322 | * @param mixed $key |
||
| 1323 | * |
||
| 1324 | * @return bool |
||
| 1325 | */ |
||
| 1326 | public function has($key) |
||
| 1333 | |||
| 1334 | /** |
||
| 1335 | * Implodes an array. |
||
| 1336 | * |
||
| 1337 | * @param string $glue |
||
| 1338 | * |
||
| 1339 | * @return string |
||
| 1340 | */ |
||
| 1341 | public function implode($glue = '') |
||
| 1345 | |||
| 1346 | 3 | /** |
|
| 1347 | * Given a list and an iterate-function that returns |
||
| 1348 | 3 | * a key for each element in the list (or a property name), |
|
| 1349 | 3 | * returns an object with an index of each item. |
|
| 1350 | 2 | * |
|
| 1351 | 2 | * Just like groupBy, but for when you know your keys are unique. |
|
| 1352 | 3 | * |
|
| 1353 | * @param mixed $key |
||
| 1354 | 3 | * |
|
| 1355 | * @return static <p>(Immutable)</p> |
||
| 1356 | */ |
||
| 1357 | public function indexBy($key) |
||
| 1369 | |||
| 1370 | /** |
||
| 1371 | * alias: for "Arrayy->searchIndex()" |
||
| 1372 | * |
||
| 1373 | * @see Arrayy::searchIndex() |
||
| 1374 | * |
||
| 1375 | * @param mixed $value <p>The value to search for.</p> |
||
| 1376 | * |
||
| 1377 | * @return mixed |
||
| 1378 | 12 | */ |
|
| 1379 | public function indexOf($value) |
||
| 1383 | |||
| 1384 | /** |
||
| 1385 | * Get everything but the last..$to items. |
||
| 1386 | * |
||
| 1387 | * @param int $to |
||
| 1388 | * |
||
| 1389 | * @return static <p>(Immutable)</p> |
||
| 1390 | */ |
||
| 1391 | public function initial($to = 1) |
||
| 1397 | 18 | ||
| 1398 | /** |
||
| 1399 | * Internal mechanics of remove method. |
||
| 1400 | * |
||
| 1401 | * @param string $key |
||
| 1402 | * |
||
| 1403 | * @return boolean |
||
| 1404 | */ |
||
| 1405 | protected function internalRemove($key) |
||
| 1426 | |||
| 1427 | /** |
||
| 1428 | * Internal mechanic of set method. |
||
| 1429 | 28 | * |
|
| 1430 | 28 | * @param string $key |
|
| 1431 | * @param mixed $value |
||
| 1432 | * |
||
| 1433 | 28 | * @return bool |
|
| 1434 | 2 | */ |
|
| 1435 | protected function internalSet($key, $value) |
||
| 1463 | |||
| 1464 | /** |
||
| 1465 | * Return an array with all elements found in input array. |
||
| 1466 | * |
||
| 1467 | * @param array $search |
||
| 1468 | * |
||
| 1469 | * @return static <p>(Immutable)</p> |
||
| 1470 | 1 | */ |
|
| 1471 | public function intersection(array $search) |
||
| 1475 | |||
| 1476 | /** |
||
| 1477 | * Return a boolean flag which indicates whether the two input arrays have any common elements. |
||
| 1478 | * |
||
| 1479 | * @param array $search |
||
| 1480 | * |
||
| 1481 | * @return bool |
||
| 1482 | */ |
||
| 1483 | 1 | public function intersects(array $search) |
|
| 1487 | 1 | ||
| 1488 | 1 | /** |
|
| 1489 | * Invoke a function on all of an array's values. |
||
| 1490 | * |
||
| 1491 | 1 | * @param mixed $callable |
|
| 1492 | 1 | * @param mixed $arguments |
|
| 1493 | 1 | * |
|
| 1494 | 1 | * @return static <p>(Immutable)</p> |
|
| 1495 | */ |
||
| 1496 | public function invoke($callable, $arguments = array()) |
||
| 1512 | 13 | ||
| 1513 | 11 | /** |
|
| 1514 | * Check whether array is associative or not. |
||
| 1515 | 3 | * |
|
| 1516 | * @return bool <p>Returns true if associative, false otherwise.</p> |
||
| 1517 | 3 | */ |
|
| 1518 | public function isAssoc() |
||
| 1532 | |||
| 1533 | /** |
||
| 1534 | * Check whether the array is empty or not. |
||
| 1535 | * |
||
| 1536 | * @return bool <p>Returns true if empty, false otherwise.</p> |
||
| 1537 | */ |
||
| 1538 | public function isEmpty() |
||
| 1542 | |||
| 1543 | /** |
||
| 1544 | * Check if the current array is equal to the given "$array" or not. |
||
| 1545 | * |
||
| 1546 | * @param array $array |
||
| 1547 | 14 | * |
|
| 1548 | * @return bool |
||
| 1549 | 14 | */ |
|
| 1550 | public function isEqual(array $array) |
||
| 1554 | |||
| 1555 | /** |
||
| 1556 | * Check if the current array is a multi-array. |
||
| 1557 | 5 | * |
|
| 1558 | * @return bool |
||
| 1559 | 5 | */ |
|
| 1560 | 2 | public function isMultiArray() |
|
| 1564 | 4 | ||
| 1565 | 2 | /** |
|
| 1566 | * Check whether array is numeric or not. |
||
| 1567 | 3 | * |
|
| 1568 | * @return bool <p>Returns true if numeric, false otherwise.</p> |
||
| 1569 | 2 | */ |
|
| 1570 | public function isNumeric() |
||
| 1584 | |||
| 1585 | /** |
||
| 1586 | * Check if the current array is sequential [0, 1, 2, 3, 4, 5 ...] or not. |
||
| 1587 | 25 | * |
|
| 1588 | * @return bool |
||
| 1589 | 25 | */ |
|
| 1590 | public function isSequential() |
||
| 1594 | |||
| 1595 | /** |
||
| 1596 | * Get all keys from the current array. |
||
| 1597 | 4 | * |
|
| 1598 | * @return static <p>(Immutable)</p> |
||
| 1599 | 4 | */ |
|
| 1600 | public function keys() |
||
| 1604 | |||
| 1605 | /** |
||
| 1606 | * Get the last value from the current array. |
||
| 1607 | * |
||
| 1608 | * @return mixed <p>Return null if there wasn't a element.</p> |
||
| 1609 | 13 | */ |
|
| 1610 | public function last() |
||
| 1614 | |||
| 1615 | 12 | /** |
|
| 1616 | 8 | * Get the last value(s) from the current array. |
|
| 1617 | * |
||
| 1618 | 8 | * @param int|null $number |
|
| 1619 | 1 | * |
|
| 1620 | 1 | * @return static <p>(Immutable)</p> |
|
| 1621 | 7 | */ |
|
| 1622 | public function lastsImmutable($number = null) |
||
| 1645 | |||
| 1646 | 12 | /** |
|
| 1647 | 8 | * Get the last value(s) from the current array. |
|
| 1648 | * |
||
| 1649 | 8 | * @param int|null $number |
|
| 1650 | 1 | * |
|
| 1651 | 1 | * @return static <p>(Mutable)</p> |
|
| 1652 | 7 | */ |
|
| 1653 | public function lastsMutable($number = null) |
||
| 1676 | |||
| 1677 | /** |
||
| 1678 | * Count the values from the current array. |
||
| 1679 | * |
||
| 1680 | * alias: for "Arrayy->size()" |
||
| 1681 | * |
||
| 1682 | * @see Arrayy::size() |
||
| 1683 | * |
||
| 1684 | * @return int |
||
| 1685 | */ |
||
| 1686 | 4 | public function length() |
|
| 1690 | 4 | ||
| 1691 | /** |
||
| 1692 | * Apply the given function to the every element of the array, |
||
| 1693 | * collecting the results. |
||
| 1694 | * |
||
| 1695 | * @param callable $callable |
||
| 1696 | * |
||
| 1697 | * @return static <p>(Immutable) Arrayy object with modified elements.</p> |
||
| 1698 | */ |
||
| 1699 | public function map($callable) |
||
| 1705 | |||
| 1706 | /** |
||
| 1707 | 13 | * Check if all items in current array match a truth test. |
|
| 1708 | * |
||
| 1709 | 13 | * @param \Closure $closure |
|
| 1710 | 13 | * |
|
| 1711 | * @return bool |
||
| 1712 | 13 | */ |
|
| 1713 | 7 | View Code Duplication | public function matches(\Closure $closure) |
| 1732 | |||
| 1733 | /** |
||
| 1734 | 12 | * Check if any item in the current array matches a truth test. |
|
| 1735 | * |
||
| 1736 | 12 | * @param \Closure $closure |
|
| 1737 | 12 | * |
|
| 1738 | * @return bool |
||
| 1739 | 12 | */ |
|
| 1740 | 9 | View Code Duplication | public function matchesAny(\Closure $closure) |
| 1759 | |||
| 1760 | /** |
||
| 1761 | * Get the max value from an array. |
||
| 1762 | * |
||
| 1763 | * @return mixed |
||
| 1764 | */ |
||
| 1765 | public function max() |
||
| 1773 | 25 | ||
| 1774 | 4 | /** |
|
| 1775 | 4 | * Merge the new $array into the current array. |
|
| 1776 | 21 | * |
|
| 1777 | * - keep key,value from the current array, also if the index is in the new $array |
||
| 1778 | * |
||
| 1779 | 25 | * @param array $array |
|
| 1780 | * @param bool $recursive |
||
| 1781 | * |
||
| 1782 | * @return static <p>(Immutable)</p> |
||
| 1783 | */ |
||
| 1784 | View Code Duplication | public function mergeAppendKeepIndex(array $array = array(), $recursive = false) |
|
| 1794 | |||
| 1795 | 16 | /** |
|
| 1796 | 4 | * Merge the new $array into the current array. |
|
| 1797 | 4 | * |
|
| 1798 | 12 | * - replace duplicate assoc-keys from the current array with the key,values from the new $array |
|
| 1799 | * - create new indexes |
||
| 1800 | * |
||
| 1801 | 16 | * @param array $array |
|
| 1802 | * @param bool $recursive |
||
| 1803 | * |
||
| 1804 | * @return static <p>(Immutable)</p> |
||
| 1805 | */ |
||
| 1806 | View Code Duplication | public function mergeAppendNewIndex(array $array = array(), $recursive = false) |
|
| 1816 | 16 | ||
| 1817 | 4 | /** |
|
| 1818 | 4 | * Merge the the current array into the $array. |
|
| 1819 | 12 | * |
|
| 1820 | * - use key,value from the new $array, also if the index is in the current array |
||
| 1821 | * |
||
| 1822 | 16 | * @param array $array |
|
| 1823 | * @param bool $recursive |
||
| 1824 | * |
||
| 1825 | * @return static <p>(Immutable)</p> |
||
| 1826 | */ |
||
| 1827 | View Code Duplication | public function mergePrependKeepIndex(array $array = array(), $recursive = false) |
|
| 1837 | |||
| 1838 | 16 | /** |
|
| 1839 | 4 | * Merge the current array into the new $array. |
|
| 1840 | 4 | * |
|
| 1841 | 12 | * - replace duplicate assoc-keys from new $array with the key,values from the current array |
|
| 1842 | * - create new indexes |
||
| 1843 | * |
||
| 1844 | 16 | * @param array $array |
|
| 1845 | * @param bool $recursive |
||
| 1846 | * |
||
| 1847 | * @return static <p>(Immutable)</p> |
||
| 1848 | */ |
||
| 1849 | View Code Duplication | public function mergePrependNewIndex(array $array = array(), $recursive = false) |
|
| 1859 | |||
| 1860 | /** |
||
| 1861 | * Get the min value from an array. |
||
| 1862 | * |
||
| 1863 | * @return mixed |
||
| 1864 | */ |
||
| 1865 | public function min() |
||
| 1873 | |||
| 1874 | /** |
||
| 1875 | * Get a subset of the items from the given array. |
||
| 1876 | * |
||
| 1877 | * @param mixed[] $keys |
||
| 1878 | * |
||
| 1879 | * @return static <p>(Immutable)</p> |
||
| 1880 | */ |
||
| 1881 | public function only(array $keys) |
||
| 1887 | 4 | ||
| 1888 | /** |
||
| 1889 | * Pad array to the specified size with a given value. |
||
| 1890 | * |
||
| 1891 | * @param int $size <p>Size of the result array.</p> |
||
| 1892 | * @param mixed $value <p>Empty value by default.</p> |
||
| 1893 | * |
||
| 1894 | * @return static <p>(Immutable) Arrayy object padded to $size with $value.</p> |
||
| 1895 | 16 | */ |
|
| 1896 | public function pad($size, $value) |
||
| 1902 | |||
| 1903 | /** |
||
| 1904 | * Pop a specified value off the end of the current array. |
||
| 1905 | * |
||
| 1906 | * @return mixed <p>(Mutable) The popped element from the current array.</p> |
||
| 1907 | */ |
||
| 1908 | 8 | public function pop() |
|
| 1912 | 8 | ||
| 1913 | /** |
||
| 1914 | 1 | * Prepend a value to the current array. |
|
| 1915 | * |
||
| 1916 | * @param mixed $value |
||
| 1917 | 8 | * @param mixed $key |
|
| 1918 | * |
||
| 1919 | * @return static <p>(Mutable) Return this Arrayy object, with the prepended value.</p> |
||
| 1920 | */ |
||
| 1921 | public function prepend($value, $key = null) |
||
| 1932 | 4 | ||
| 1933 | /** |
||
| 1934 | * Push one or more values onto the end of array at once. |
||
| 1935 | * |
||
| 1936 | * @return static <p>(Mutable) Return this Arrayy object, with pushed elements to the end of array.</p> |
||
| 1937 | */ |
||
| 1938 | View Code Duplication | public function push(/* variadic arguments allowed */) |
|
| 1947 | |||
| 1948 | 17 | /** |
|
| 1949 | 14 | * Get a random value from the current array. |
|
| 1950 | * |
||
| 1951 | 14 | * @param null|int $number <p>How many values you will take?</p> |
|
| 1952 | * |
||
| 1953 | * @return static <p>(Immutable)</p> |
||
| 1954 | 5 | */ |
|
| 1955 | 5 | public function randomImmutable($number = null) |
|
| 1972 | |||
| 1973 | /** |
||
| 1974 | * Pick a random key/index from the keys of this array. |
||
| 1975 | 4 | * |
|
| 1976 | * @return mixed <p>Get a key/index or null if there wasn't a key/index.</p> |
||
| 1977 | * |
||
| 1978 | * @throws \RangeException If array is empty |
||
| 1979 | */ |
||
| 1980 | public function randomKey() |
||
| 1990 | 14 | ||
| 1991 | /** |
||
| 1992 | 14 | * Pick a given number of random keys/indexes out of this array. |
|
| 1993 | 3 | * |
|
| 1994 | 3 | * @param int $number <p>The number of keys/indexes (should be <= $this->count())</p> |
|
| 1995 | 3 | * |
|
| 1996 | 3 | * @return static <p>(Immutable)</p> |
|
| 1997 | * |
||
| 1998 | 3 | * @throws \RangeException If array is empty |
|
| 1999 | 3 | */ |
|
| 2000 | public function randomKeys($number) |
||
| 2019 | |||
| 2020 | 17 | /** |
|
| 2021 | 7 | * Get a random value from the current array. |
|
| 2022 | 7 | * |
|
| 2023 | * @param null|int $number <p>How many values you will take?</p> |
||
| 2024 | 7 | * |
|
| 2025 | * @return static <p>(Mutable)</p> |
||
| 2026 | */ |
||
| 2027 | 11 | public function randomMutable($number = null) |
|
| 2044 | |||
| 2045 | 4 | /** |
|
| 2046 | * Pick a random value from the values of this array. |
||
| 2047 | * |
||
| 2048 | * @return mixed <p>Get a random value or null if there wasn't a value.</p> |
||
| 2049 | */ |
||
| 2050 | public function randomValue() |
||
| 2060 | |||
| 2061 | /** |
||
| 2062 | * Pick a given number of random values out of this array. |
||
| 2063 | * |
||
| 2064 | * @param int $number |
||
| 2065 | * |
||
| 2066 | * @return static <p>(Mutable)</p> |
||
| 2067 | */ |
||
| 2068 | public function randomValues($number) |
||
| 2074 | 9 | ||
| 2075 | 9 | /** |
|
| 2076 | 9 | * Get a random value from an array, with the ability to skew the results. |
|
| 2077 | 2 | * |
|
| 2078 | 1 | * Example: randomWeighted(['foo' => 1, 'bar' => 2]) has a 66% chance of returning bar. |
|
| 2079 | 1 | * |
|
| 2080 | 2 | * @param array $array |
|
| 2081 | 9 | * @param null|int $number <p>How many values you will take?</p> |
|
| 2082 | * |
||
| 2083 | 9 | * @return static <p>(Immutable)</p> |
|
| 2084 | */ |
||
| 2085 | public function randomWeighted(array $array, $number = null) |
||
| 2098 | 3 | ||
| 2099 | /** |
||
| 2100 | * Reduce the current array via callable e.g. anonymous-function. |
||
| 2101 | 3 | * |
|
| 2102 | * @param mixed $callable |
||
| 2103 | * @param array $init |
||
| 2104 | 3 | * |
|
| 2105 | * @return static <p>(Immutable)</p> |
||
| 2106 | */ |
||
| 2107 | public function reduce($callable, array $init = array()) |
||
| 2119 | |||
| 2120 | /** |
||
| 2121 | * Create a numerically re-indexed Arrayy object. |
||
| 2122 | * |
||
| 2123 | * @return static <p>(Mutable) Return this Arrayy object, with re-indexed array-elements.</p> |
||
| 2124 | */ |
||
| 2125 | public function reindex() |
||
| 2131 | 1 | ||
| 2132 | 1 | /** |
|
| 2133 | 1 | * Return all items that fail the truth test. |
|
| 2134 | 1 | * |
|
| 2135 | * @param \Closure $closure |
||
| 2136 | 1 | * |
|
| 2137 | * @return static <p>(Immutable)</p> |
||
| 2138 | */ |
||
| 2139 | View Code Duplication | public function reject(\Closure $closure) |
|
| 2151 | |||
| 2152 | /** |
||
| 2153 | * Remove a value from the current array (optional using dot-notation). |
||
| 2154 | * |
||
| 2155 | * @param mixed $key |
||
| 2156 | * |
||
| 2157 | 18 | * @return static <p>(Immutable)</p> |
|
| 2158 | */ |
||
| 2159 | 18 | public function remove($key) |
|
| 2174 | |||
| 2175 | /** |
||
| 2176 | * Remove the first value from the current array. |
||
| 2177 | * |
||
| 2178 | * @return static <p>(Immutable)</p> |
||
| 2179 | */ |
||
| 2180 | 7 | public function removeFirst() |
|
| 2187 | |||
| 2188 | /** |
||
| 2189 | * Remove the last value from the current array. |
||
| 2190 | * |
||
| 2191 | * @return static <p>(Immutable)</p> |
||
| 2192 | */ |
||
| 2193 | public function removeLast() |
||
| 2200 | 6 | ||
| 2201 | /** |
||
| 2202 | * Removes a particular value from an array (numeric or associative). |
||
| 2203 | 6 | * |
|
| 2204 | 6 | * @param mixed $value |
|
| 2205 | 7 | * |
|
| 2206 | * @return static <p>(Immutable)</p> |
||
| 2207 | 7 | */ |
|
| 2208 | 7 | public function removeValue($value) |
|
| 2226 | |||
| 2227 | 2 | /** |
|
| 2228 | * Replace a key with a new key/value pair. |
||
| 2229 | * |
||
| 2230 | * @param $replace |
||
| 2231 | * @param $key |
||
| 2232 | * @param $value |
||
| 2233 | * |
||
| 2234 | * @return static <p>(Immutable)</p> |
||
| 2235 | */ |
||
| 2236 | public function replace($replace, $key, $value) |
||
| 2242 | |||
| 2243 | /** |
||
| 2244 | * Create an array using the current array as values and the other array as keys. |
||
| 2245 | * |
||
| 2246 | * @param array $keys <p>An array of keys.</p> |
||
| 2247 | * |
||
| 2248 | * @return static <p>(Immutable) Arrayy object with keys from the other array.</p> |
||
| 2249 | */ |
||
| 2250 | public function replaceAllKeys(array $keys) |
||
| 2256 | |||
| 2257 | /** |
||
| 2258 | * Create an array using the current array as keys and the other array as values. |
||
| 2259 | * |
||
| 2260 | * @param array $array <p>An array o values.</p> |
||
| 2261 | * |
||
| 2262 | * @return static <p>(Immutable) Arrayy object with values from the other array.</p> |
||
| 2263 | */ |
||
| 2264 | public function replaceAllValues(array $array) |
||
| 2270 | 1 | ||
| 2271 | /** |
||
| 2272 | * Replace the keys in an array with another set. |
||
| 2273 | * |
||
| 2274 | * @param array $keys <p>An array of keys matching the array's size</p> |
||
| 2275 | * |
||
| 2276 | * @return static <p>(Immutable)</p> |
||
| 2277 | */ |
||
| 2278 | public function replaceKeys(array $keys) |
||
| 2285 | |||
| 2286 | 3 | /** |
|
| 2287 | 3 | * Replace the first matched value in an array. |
|
| 2288 | 3 | * |
|
| 2289 | * @param mixed $search |
||
| 2290 | 3 | * @param mixed $replacement |
|
| 2291 | * |
||
| 2292 | * @return static <p>(Immutable)</p> |
||
| 2293 | */ |
||
| 2294 | public function replaceOneValue($search, $replacement = '') |
||
| 2305 | 1 | ||
| 2306 | /** |
||
| 2307 | 1 | * Replace values in the current array. |
|
| 2308 | * |
||
| 2309 | 1 | * @param string $search <p>The string to replace.</p> |
|
| 2310 | * @param string $replacement <p>What to replace it with.</p> |
||
| 2311 | * |
||
| 2312 | * @return static <p>(Immutable)</p> |
||
| 2313 | */ |
||
| 2314 | public function replaceValues($search, $replacement = '') |
||
| 2324 | |||
| 2325 | /** |
||
| 2326 | * Get the last elements from index $from until the end of this array. |
||
| 2327 | * |
||
| 2328 | * @param int $from |
||
| 2329 | * |
||
| 2330 | * @return static <p>(Immutable)</p> |
||
| 2331 | */ |
||
| 2332 | public function rest($from = 1) |
||
| 2338 | 1 | ||
| 2339 | /** |
||
| 2340 | 1 | * Move an array element to a new index. |
|
| 2341 | 1 | * |
|
| 2342 | 1 | * cherry-picked from: http://stackoverflow.com/questions/12624153/move-an-array-element-to-a-new-index-in-php |
|
| 2343 | 1 | * |
|
| 2344 | 1 | * @param int|string $from |
|
| 2345 | 1 | * @param int|string $to |
|
| 2346 | 1 | * |
|
| 2347 | 1 | * @return static <p>(Immutable)</p> |
|
| 2348 | 1 | */ |
|
| 2349 | 1 | public function moveElement($from, $to) |
|
| 2376 | |||
| 2377 | /** |
||
| 2378 | * Return the array in the reverse order. |
||
| 2379 | * |
||
| 2380 | * @return static <p>(Mutable) Return this Arrayy object.</p> |
||
| 2381 | */ |
||
| 2382 | public function reverse() |
||
| 2388 | |||
| 2389 | /** |
||
| 2390 | * Search for the first index of the current array via $value. |
||
| 2391 | * |
||
| 2392 | * @param mixed $value |
||
| 2393 | * |
||
| 2394 | * @return int|float|string |
||
| 2395 | 9 | */ |
|
| 2396 | public function searchIndex($value) |
||
| 2400 | 9 | ||
| 2401 | /** |
||
| 2402 | * Search for the value of the current array via $index. |
||
| 2403 | * |
||
| 2404 | * @param mixed $index |
||
| 2405 | 9 | * |
|
| 2406 | 1 | * @return static <p>(Immutable) Will return a empty Arrayy if the value wasn't found.</p> |
|
| 2407 | 1 | */ |
|
| 2408 | public function searchValue($index) |
||
| 2429 | 17 | ||
| 2430 | /** |
||
| 2431 | * Set a value for the current array (optional using dot-notation). |
||
| 2432 | * |
||
| 2433 | * @param string $key <p>The key to set.</p> |
||
| 2434 | * @param mixed $value <p>Its value.</p> |
||
| 2435 | * |
||
| 2436 | * @return static <p>(Immutable)</p> |
||
| 2437 | */ |
||
| 2438 | public function set($key, $value) |
||
| 2444 | |||
| 2445 | 11 | /** |
|
| 2446 | 4 | * Get a value from a array and set it if it was not. |
|
| 2447 | 4 | * |
|
| 2448 | * WARNING: this method only set the value, if the $key is not already set |
||
| 2449 | 11 | * |
|
| 2450 | * @param string $key <p>The key</p> |
||
| 2451 | * @param mixed $fallback <p>The default value to set if it isn't.</p> |
||
| 2452 | * |
||
| 2453 | * @return mixed <p>(Mutable)</p> |
||
| 2454 | */ |
||
| 2455 | public function setAndGet($key, $fallback = null) |
||
| 2464 | |||
| 2465 | /** |
||
| 2466 | * Shifts a specified value off the beginning of array. |
||
| 2467 | 1 | * |
|
| 2468 | * @return mixed <p>(Mutable) A shifted element from the current array.</p> |
||
| 2469 | 1 | */ |
|
| 2470 | public function shift() |
||
| 2474 | |||
| 2475 | /** |
||
| 2476 | * Shuffle the current array. |
||
| 2477 | * |
||
| 2478 | * @return static <p>(Immutable)</p> |
||
| 2479 | */ |
||
| 2480 | public function shuffle() |
||
| 2488 | |||
| 2489 | /** |
||
| 2490 | * Get the size of an array. |
||
| 2491 | * |
||
| 2492 | * @return int |
||
| 2493 | */ |
||
| 2494 | public function size() |
||
| 2498 | |||
| 2499 | 4 | /** |
|
| 2500 | * Extract a slice of the array. |
||
| 2501 | * |
||
| 2502 | * @param int $offset <p>Slice begin index.</p> |
||
| 2503 | * @param int|null $length <p>Length of the slice.</p> |
||
| 2504 | * @param bool $preserveKeys <p>Whether array keys are preserved or no.</p> |
||
| 2505 | * |
||
| 2506 | * @return static <p>A slice of the original array with length $length.</p> |
||
| 2507 | */ |
||
| 2508 | public function slice($offset, $length = null, $preserveKeys = false) |
||
| 2514 | |||
| 2515 | 19 | /** |
|
| 2516 | * Sort the current array and optional you can keep the keys. |
||
| 2517 | * |
||
| 2518 | * @param integer $direction <p>use <strong>SORT_ASC</strong> (default) or <strong>SORT_DESC</strong></p> |
||
| 2519 | * @param integer $strategy <p>use e.g.: <strong>SORT_REGULAR</strong> (default) or <strong>SORT_NATURAL</strong></p> |
||
| 2520 | * @param bool $keepKeys |
||
| 2521 | * |
||
| 2522 | * @return static <p>(Mutable) Return this Arrayy object.</p> |
||
| 2523 | */ |
||
| 2524 | public function sort($direction = SORT_ASC, $strategy = SORT_REGULAR, $keepKeys = false) |
||
| 2530 | 18 | ||
| 2531 | /** |
||
| 2532 | 18 | * Sort the current array by key. |
|
| 2533 | * |
||
| 2534 | 18 | * @link http://php.net/manual/en/function.ksort.php |
|
| 2535 | * @link http://php.net/manual/en/function.krsort.php |
||
| 2536 | * |
||
| 2537 | * @param int|string $direction <p>use <strong>SORT_ASC</strong> (default) or <strong>SORT_DESC</strong></p> |
||
| 2538 | * @param int $strategy <p>use e.g.: <strong>SORT_REGULAR</strong> (default) or |
||
| 2539 | * <strong>SORT_NATURAL</strong></p> |
||
| 2540 | * |
||
| 2541 | * @return static <p>(Mutable) Return this Arrayy object.</p> |
||
| 2542 | */ |
||
| 2543 | public function sortKeys($direction = SORT_ASC, $strategy = SORT_REGULAR) |
||
| 2549 | |||
| 2550 | /** |
||
| 2551 | * Sort the current array by value. |
||
| 2552 | * |
||
| 2553 | * @param int $direction <p>use <strong>SORT_ASC</strong> (default) or <strong>SORT_DESC</strong></p> |
||
| 2554 | * @param int $strategy <p>use e.g.: <strong>SORT_REGULAR</strong> (default) or <strong>SORT_NATURAL</strong></p> |
||
| 2555 | * |
||
| 2556 | * @return static <p>(Immutable)</p> |
||
| 2557 | */ |
||
| 2558 | 1 | public function sortValueKeepIndex($direction = SORT_ASC, $strategy = SORT_REGULAR) |
|
| 2562 | |||
| 2563 | /** |
||
| 2564 | * Sort the current array by value. |
||
| 2565 | * |
||
| 2566 | * @param int $direction <p>use <strong>SORT_ASC</strong> (default) or <strong>SORT_DESC</strong></p> |
||
| 2567 | * @param int $strategy <p>use e.g.: <strong>SORT_REGULAR</strong> (default) or <strong>SORT_NATURAL</strong></p> |
||
| 2568 | * |
||
| 2569 | * @return static <p>(Immutable)</p> |
||
| 2570 | */ |
||
| 2571 | public function sortValueNewIndex($direction = SORT_ASC, $strategy = SORT_REGULAR) |
||
| 2575 | |||
| 2576 | 1 | /** |
|
| 2577 | * Sort a array by value, by a closure or by a property. |
||
| 2578 | 1 | * |
|
| 2579 | 1 | * - If the sorter is null, the array is sorted naturally. |
|
| 2580 | * - Associative (string) keys will be maintained, but numeric keys will be re-indexed. |
||
| 2581 | * |
||
| 2582 | 1 | * @param null $sorter |
|
| 2583 | 1 | * @param string|int $direction <p>use <strong>SORT_ASC</strong> (default) or <strong>SORT_DESC</strong></p> |
|
| 2584 | * @param int $strategy <p>use e.g.: <strong>SORT_REGULAR</strong> (default) or |
||
| 2585 | 1 | * <strong>SORT_NATURAL</strong></p> |
|
| 2586 | 1 | * |
|
| 2587 | * @return static <p>(Immutable)</p> |
||
| 2588 | 1 | */ |
|
| 2589 | public function sorter($sorter = null, $direction = SORT_ASC, $strategy = SORT_REGULAR) |
||
| 2615 | |||
| 2616 | /** |
||
| 2617 | 18 | * sorting keys |
|
| 2618 | 18 | * |
|
| 2619 | 6 | * @param array $elements |
|
| 2620 | 6 | * @param int $direction <p>use <strong>SORT_ASC</strong> (default) or <strong>SORT_DESC</strong></p> |
|
| 2621 | 13 | * @param int $strategy <p>use e.g.: <strong>SORT_REGULAR</strong> (default) or <strong>SORT_NATURAL</strong></p> |
|
| 2622 | 13 | * |
|
| 2623 | 13 | * @return void <p>Mutable</p> |
|
| 2624 | 13 | */ |
|
| 2625 | 13 | protected function sorterKeys(array &$elements, $direction = SORT_ASC, $strategy = SORT_REGULAR) |
|
| 2640 | |||
| 2641 | 19 | /** |
|
| 2642 | 19 | * @param array &$elements |
|
| 2643 | 19 | * @param int|string $direction <p>use <strong>SORT_ASC</strong> (default) or <strong>SORT_DESC</strong></p> |
|
| 2644 | * @param int $strategy <p>use e.g.: <strong>SORT_REGULAR</strong> (default) or |
||
| 2645 | * <strong>SORT_NATURAL</strong></p> |
||
| 2646 | 19 | * @param bool $keepKeys |
|
| 2647 | 19 | * |
|
| 2648 | 9 | * @return void <p>Mutable</p> |
|
| 2649 | 5 | */ |
|
| 2650 | 5 | protected function sorting(array &$elements, $direction = SORT_ASC, $strategy = SORT_REGULAR, $keepKeys = false) |
|
| 2677 | 1 | ||
| 2678 | 1 | /** |
|
| 2679 | 1 | * Split an array in the given amount of pieces. |
|
| 2680 | 1 | * |
|
| 2681 | 1 | * @param int $numberOfPieces |
|
| 2682 | 1 | * @param bool $keepKeys |
|
| 2683 | * |
||
| 2684 | * @return static <p>(Immutable)</p> |
||
| 2685 | 1 | */ |
|
| 2686 | public function split($numberOfPieces = 2, $keepKeys = false) |
||
| 2700 | |||
| 2701 | 1 | /** |
|
| 2702 | * Stripe all empty items. |
||
| 2703 | 1 | * |
|
| 2704 | * @return static <p>(Immutable)</p> |
||
| 2705 | */ |
||
| 2706 | public function stripEmpty() |
||
| 2718 | 1 | ||
| 2719 | /** |
||
| 2720 | 1 | * Swap two values between positions by key. |
|
| 2721 | * |
||
| 2722 | * @param string|int $swapA <p>a key in the array</p> |
||
| 2723 | * @param string|int $swapB <p>a key in the array</p> |
||
| 2724 | * |
||
| 2725 | * @return static <p>(Immutable)</p> |
||
| 2726 | */ |
||
| 2727 | public function swap($swapA, $swapB) |
||
| 2735 | |||
| 2736 | /** |
||
| 2737 | * alias: for "Arrayy->getArray()" |
||
| 2738 | * |
||
| 2739 | * @see Arrayy::getArray() |
||
| 2740 | 5 | */ |
|
| 2741 | public function toArray() |
||
| 2745 | |||
| 2746 | /** |
||
| 2747 | * Convert the current array to JSON. |
||
| 2748 | * |
||
| 2749 | * @param null|int $options <p>e.g. JSON_PRETTY_PRINT</p> |
||
| 2750 | * |
||
| 2751 | * @return string |
||
| 2752 | 19 | */ |
|
| 2753 | public function toJson($options = null) |
||
| 2757 | |||
| 2758 | /** |
||
| 2759 | * Implodes array to a string with specified separator. |
||
| 2760 | * |
||
| 2761 | * @param string $separator <p>The element's separator.</p> |
||
| 2762 | * |
||
| 2763 | * @return string <p>The string representation of array, separated by ",".</p> |
||
| 2764 | 9 | */ |
|
| 2765 | public function toString($separator = ',') |
||
| 2769 | |||
| 2770 | /** |
||
| 2771 | * alias: for "Arrayy->unique()" |
||
| 2772 | * |
||
| 2773 | * @see Arrayy::unique() |
||
| 2774 | 9 | * |
|
| 2775 | * @return static <p>(Mutable) Return this Arrayy object, with the appended values.</p> |
||
| 2776 | 9 | */ |
|
| 2777 | 9 | public function uniqueNewIndex() |
|
| 2781 | 8 | ||
| 2782 | /** |
||
| 2783 | 8 | * Return a duplicate free copy of the current array. |
|
| 2784 | 9 | * |
|
| 2785 | 9 | * @return static <p>(Mutable)</p> |
|
| 2786 | 9 | */ |
|
| 2787 | public function unique() |
||
| 2809 | 9 | ||
| 2810 | 8 | /** |
|
| 2811 | 8 | * Return a duplicate free copy of the current array. (with the old keys) |
|
| 2812 | 8 | * |
|
| 2813 | * @return static <p>(Mutable)</p> |
||
| 2814 | 8 | */ |
|
| 2815 | 9 | public function uniqueKeepIndex() |
|
| 2840 | 4 | ||
| 2841 | /** |
||
| 2842 | * Prepends one or more values to the beginning of array at once. |
||
| 2843 | * |
||
| 2844 | * @return static <p>(Mutable) Return this Arrayy object, with prepended elements to the beginning of array.</p> |
||
| 2845 | */ |
||
| 2846 | View Code Duplication | public function unshift(/* variadic arguments allowed */) |
|
| 2855 | |||
| 2856 | /** |
||
| 2857 | * Get all values from a array. |
||
| 2858 | * |
||
| 2859 | * @return static <p>(Immutable)</p> |
||
| 2860 | */ |
||
| 2861 | 9 | public function values() |
|
| 2865 | 4 | ||
| 2866 | 5 | /** |
|
| 2867 | * Apply the given function to every element in the array, discarding the results. |
||
| 2868 | * |
||
| 2869 | 9 | * @param callable $callable |
|
| 2870 | * @param bool $recursive <p>Whether array will be walked recursively or no</p> |
||
| 2871 | * |
||
| 2872 | * @return static <p>(Mutable) Return this Arrayy object, with modified elements.</p> |
||
| 2873 | */ |
||
| 2874 | public function walk($callable, $recursive = false) |
||
| 2884 | |||
| 2885 | } |
||
| 2886 |
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.