Class NestedHashMap
Wraps a multi-dimensional associated array object (nested hash map) and
provides dot notation access to it along with a few other nicities, like
default values and assertHas.
Examples:
$items = array( "foo" => array( "bar" => "baz" ));
$arr = new NestedHashMap($items); $arr->get("foo.bar"); // "baz" $arr->has("foo.bar"); // true
Methods summary
public
|
#
__construct( array $items = array() )
Create a new NestedHashMap object wrapping $items.
Create a new NestedHashMap object wrapping $items.
Parameters
|
public
array
|
#
getAll( )
Returns the entire multi-array.
Returns the entire multi-array.
Returns
array
|
public
mixed
|
#
get( string $key, mixed $default = null )
Get a key's value.
Parameters
Returns
mixed
Throws
InvalidArgumentException
|
public
boolean
|
#
has( string $key )
Check if an item exists in the multi-array.
Check if an item exists in the multi-array.
Parameters
Returns
boolean
|
public
|
#
set( string $key, mixed $value )
Set a key's value.
Parameters
|
public
boolean
|
#
assertHas( string $key,… )
Throws an exception if one or more of the given keys
do not exist in the multi-array.
Throws an exception if one or more of the given keys
do not exist in the multi-array.
Parameters
Returns
boolean
Throws
RuntimeException
|
protected
mixed
|
#
lookup( array $items, string $piece )
Looks up the key ($piece) in the given array ($items)
Looks up the key ($piece) in the given array ($items)
Parameters
Returns
mixed
Throws
InvalidArgumentException
|
Properties summary
protected
array
|
$items
|
|