PHP Класс Jyxo\Spl\ArrayUtil

Автор: Jakub Tománek
Показать файл Открыть проект

Открытые методы

Метод Описание
keymap ( Traversable $traversable, Closure $key, Closure $value = null ) : array Creates an associative array from iterator which doesn't return proper keys.
range ( mixed $low, mixed $high, Closure $step, Closure $compare = null ) : array Creates an array containing item range. Similar to range() but with closures.

Описание методов

keymap() публичный статический Метод

Keys are generated by applying callback $key to the current value. It is also possible to apply another callback directly to the value. Key callback is called BEFORE value callback. Example: $data = \Jyxo\Spl\ArrayUtil::keymap($iterator, function(Object $object) { return $object->getId(); });
public static keymap ( Traversable $traversable, Closure $key, Closure $value = null ) : array
$traversable Traversable Iterator
$key Closure Closure for generating keys
$value Closure Closure for modifying data (Optional)
Результат array

range() публичный статический Метод

Params $low and $high are inclusive. If $low > $high, resulting array will be in descending order.
public static range ( mixed $low, mixed $high, Closure $step, Closure $compare = null ) : array
$low mixed Minimal value
$high mixed Maximal value
$step Closure Closure which creates next value from current
$compare Closure comparing closure for detecting if we're at the end of the range (Optional)
Результат array