PHP Class nspl\ds\DefaultArray

Inheritance: extends ArrayObject
Show file Open project: ihor/Nspl

Protected Properties

Property Type Description
$default mixed | callable

Public Methods

Method Description
__construct ( mixed | callable $default, array $data = [] ) If you pass a function as default value it will be called without arguments to provide a default value for the given key, this value will be inserted in the array for the key, and returned.
__toString ( ) : string
fromArray ( mixed $default, array $array ) : static
offsetGet ( integer $index ) : mixed (PHP 5 >= 5.0.0)
Offset to retrieve

Private Methods

Method Description
getDefault ( )

Method Details

__construct() public method

If you pass a function as default value it will be called without arguments to provide a default value for the given key, this value will be inserted in the array for the key, and returned.
public __construct ( mixed | callable $default, array $data = [] )
$default mixed | callable
$data array Provides initial data

__toString() public method

public __toString ( ) : string
return string

fromArray() public static method

public static fromArray ( mixed $default, array $array ) : static
$default mixed
$array array
return static

offsetGet() public method

(PHP 5 >= 5.0.0)
Offset to retrieve
public offsetGet ( integer $index ) : mixed
$index integer

The offset to retrieve.

return mixed Can return all value types.

Property Details

$default protected property

protected mixed|callable $default
return mixed | callable