PHP Class Clinner\ValueHolder

Author: José Nahuel Cuesta Luengo ([email protected])
Show file Open project: ncuesta/clinner Class Usage Examples

Public Methods

Method Description
__construct ( array $initial = [] ) Constructor
__get ( $name ) Overridden in order to allow atribute-like accessor for values in the ValueHolder.
__set ( $name, $value ) Overridden in order to allow atribute-like setter for values in the ValueHolder.
count ( ) : integer Get the number of arguments set to this ValueHolder.
create ( array | ValueHolder $initial = [] ) : ValueHolder Create a new instance of ValueHolder with an optional initial set of values.
get ( string $name, mixed $default = null ) : mixed Get the value stored under key $name if it's set - otherwise return $default.
getAll ( ) : array Get all the values stored in this ValueHolder as an array.
isEmpty ( ) : boolean Answer whether this ValueHolder is empty.
reset ( ) : ValueHolder Reset this ValueHolder's values, clearing any of them.
set ( string $name, mixed $value ) : ValueHolder Set and store a value under key $name to $value.
setAll ( array $values ) : ValueHolder Set all the values stored in this ValueHolder to $values, destroying any previously-set ones.

Method Details

__construct() public method

Constructor
public __construct ( array $initial = [] )
$initial array (Optional) initial values for the ValueHolder.

__get() public method

Overridden in order to allow atribute-like accessor for values in the ValueHolder.
public __get ( $name )

__set() public method

Overridden in order to allow atribute-like setter for values in the ValueHolder.
public __set ( $name, $value )

count() public method

Get the number of arguments set to this ValueHolder.
public count ( ) : integer
return integer

create() public static method

$initial might either be an array or another instance of ValueHolder, in which case it will be returned as is.
public static create ( array | ValueHolder $initial = [] ) : ValueHolder
$initial array | ValueHolder (Optional) initial set of values.
return ValueHolder

get() public method

Get the value stored under key $name if it's set - otherwise return $default.
public get ( string $name, mixed $default = null ) : mixed
$name string The key name for the desired value.
$default mixed (Optional) a default value to return if $name is not set.
return mixed

getAll() public method

Get all the values stored in this ValueHolder as an array.
public getAll ( ) : array
return array

isEmpty() public method

Answer whether this ValueHolder is empty.
public isEmpty ( ) : boolean
return boolean

reset() public method

Reset this ValueHolder's values, clearing any of them.
public reset ( ) : ValueHolder
return ValueHolder This instance, for a fluent API.

set() public method

Set and store a value under key $name to $value.
public set ( string $name, mixed $value ) : ValueHolder
$name string The key name for the value to set.
$value mixed The value to set under key $name.
return ValueHolder This instance, for a fluent API.

setAll() public method

Set all the values stored in this ValueHolder to $values, destroying any previously-set ones.
public setAll ( array $values ) : ValueHolder
$values array The new values to set.
return ValueHolder This instance, for a fluent API.