PHP Class Kraken\Util\Support\ArraySupport

Exibir arquivo Open project: kraken-php/framework Class Usage Examples

Public Methods

Method Description
exists ( array $array, string $key ) : boolean Check if given key exists in array with dot notation support.
expand ( $array ) : array Expand flattened array into a multi-dimensional one.
flatten ( array $array ) : array Flatten a multi-dimensional array into a single level using dot notation.
get ( array $array, string $key, mixed $default = null ) : mixed Return the value stored under given key in the array with dot notation support.
isEmpty ( array $array ) : boolean Check if given array is empty.
merge ( array[] $arrays ) : array Merge several arrays, preserving dot notation.
normalizeKey ( string $key ) : string Normalize key to dot notation valid format.
remove ( &$array, string $key ) : boolean Remove the value stored under given key from the array with dot notation support.
replace ( array[] $arrays ) : array Merge several arrays.
set ( &$array, string $key, mixed $value ) : array Set the value for given key in the array with dot notation support.

Protected Methods

Method Description
flattenRecursive ( array &$recursion, string $prefix ) : array Flatten a single recursion of array.

Method Details

exists() public static method

Check if given key exists in array with dot notation support.
public static exists ( array $array, string $key ) : boolean
$array array
$key string
return boolean

expand() public static method

Expand flattened array into a multi-dimensional one.
public static expand ( $array ) : array
$array
return array

flatten() public static method

Flatten a multi-dimensional array into a single level using dot notation.
public static flatten ( array $array ) : array
$array array
return array

flattenRecursive() protected static method

Flatten a single recursion of array.
protected static flattenRecursive ( array &$recursion, string $prefix ) : array
$recursion array
$prefix string
return array

get() public static method

Return the value stored under given key in the array with dot notation support.
public static get ( array $array, string $key, mixed $default = null ) : mixed
$array array
$key string
$default mixed
return mixed

isEmpty() public static method

Check if given array is empty.
public static isEmpty ( array $array ) : boolean
$array array
return boolean

merge() public static method

Merge several arrays, preserving dot notation.
public static merge ( array[] $arrays ) : array
$arrays array[]
return array

normalizeKey() public static method

Normalize key to dot notation valid format.
public static normalizeKey ( string $key ) : string
$key string
return string

remove() public static method

Remove the value stored under given key from the array with dot notation support.
public static remove ( &$array, string $key ) : boolean
$key string
return boolean

replace() public static method

Merge several arrays.
public static replace ( array[] $arrays ) : array
$arrays array[]
return array

set() public static method

Set the value for given key in the array with dot notation support.
public static set ( &$array, string $key, mixed $value ) : array
$key string
$value mixed
return array