Property | Type | Description | |
---|---|---|---|
$array |
Method | Description | |
---|---|---|
__construct ( array $array = [] ) | Constructor. | |
add ( $key, $value ) : array | Adds an element using "dot" notation if doesn't exists. | |
flatten ( ) : array | Flatten a multi-dimensional array into a single level. | |
get ( string $key, mixed $default = null ) : mixed | Gets a value from a deeply nested array using "dot" notation. | |
getArray ( ) : array | Gets the working array. | |
has ( string $key ) : boolean | Checks if an item exists in using "dot" notation. | |
paginate ( integer $maxPerPage, integer $initialPage = 1, string $key = null ) : array | Paginates the array. | |
remove ( string $key ) : array | Removes an item using "dot" notation. | |
set ( string $key, mixed $value ) : array | Sets an item using "dot" notation. | |
setArray ( array $array ) : |
Sets the working array. | |
sort ( string $key = null, callable $callback = null ) : array | Sorts the array (ascendant by default). | |
sortBy ( callable $callback, string $key = null, integer $options = SORT_REGULAR, boolean $isDescending = false ) : array | Sort the array sing the given callback. | |
where ( callable $filter ) : array | Filter using the given callback function. |
Method | Description | |
---|---|---|
escapedDotKeyToUnderscore ( $key ) | ||
underscoreDotKeyToDot ( $key ) | ||
unescapeDotKey ( $key ) |
public paginate ( integer $maxPerPage, integer $initialPage = 1, string $key = null ) : array | ||
$maxPerPage | integer | Max items per page. If this value is minor than 1 the result will be an empty array |
$initialPage | integer | Initial page. Page 1 by default |
$key | string | Element to paginate using "dot" notation |
return | array | A list of pages with an array of elements associated with each page |
public sort ( string $key = null, callable $callback = null ) : array | ||
$key | string | Element to sort using "dot" notation. You can to escape a dot in a key surrendering with brackets: "[.]" |
$callback | callable | Callback should be a function with the following signature: ```php function($element1, $element2) { // returns -1, 0 or 1 } ``` |
return | array |
public sortBy ( callable $callback, string $key = null, integer $options = SORT_REGULAR, boolean $isDescending = false ) : array | ||
$callback | callable | Callback should be a function with the following signature: ```php function($key, $value) { // return $processedValue; } ``` |
$key | string | Element to sort using "dot" notation. You can to escape a dot in a key surrendering with brackets: "[.]" |
$options | integer | See sort_flags at http://php.net/manual/es/function.sort.php |
$isDescending | boolean | |
return | array |