\Hazaar\Model
ChildArray
Strict model child array

The ChildArray class is designed to simple wrap the standard functions of a PHP array with the difference that it is instantiated with a data type that all the values it contains will be converted to.

Tags

Version

1.0

Author

JamieCarl

Summary
Methods Properties Constants
key
No constants
Properties
$type
$type
$values
$values
Methods
__call()
__call($func, $argv) : mixed
Magic method for calling array_* functions on the ChildArray class.

Tags

Throws

BadMethodCallException

Parameters

$funcmixed

No description

$argvmixed

No description

Returns

mixed
__construct()
__construct($type, $values = Array ( ) )
ChildArray Constructor

The constructor simply takes the data type to use to convert all the items stored in this array. This is any known data type (int, bool, etc) or even an object class. We use the same DataTypeConverter class as a strict model.

Tags

Throws

\Exception

Parameters

$typemixed

The data type to convert items to.

$valuesmixed

The initial array of items to populate the object with.

array_walk()
array_walk($callback, $userdata = null)
Apply a user supplied function to every member of an array

Applies the user-defined callback function to each element of the array array.

ChildArray::walk() is not affected by the internal array pointer of array. ChildArray::walk() will walk through the entire array regardless of pointer position.

For more information on this method see PHP’s array_walk() function.

Parameters

$callbackmixed

Typically, callback takes on two parameters. The array parameter’s value being the first, and the key/index second.

$userdatamixed

If the optional userdata parameter is supplied, it will be passed as the third parameter to the callback.

array_walk_recursive()
array_walk_recursive($callback, $userdata = null)
Apply a user supplied function to every member of an array

Applies the user-defined callback function to each element of the array array.

ChildArray::walk() is not affected by the internal array pointer of array. ChildArray::walk() will walk through the entire array regardless of pointer position.

For more information on this method see PHP’s array_walk() function.

Parameters

$callbackmixed

Typically, callback takes on two parameters. The array parameter’s value being the first, and the key/index second.

$userdatamixed

If the optional userdata parameter is supplied, it will be passed as the third parameter to the callback.

count()
count()
current()
current()
Static
explode()
explode($type, $glue, $string, $limit = 'php_int_max') : ChildArray
ChildArray implementation of the explode function.

This operates mostly the same as the built-in PHP explode function except that it requires a type. The purpose of a ChildArray is to maintain data type of it’s elements so a type is required.

Parameters

$typemixed

The data type of enforce on this ChildArray.

$gluemixed

The boundary string.

$stringmixed

The input string.

$limitmixed

If limit is set and positive, the returned array will contain a maximum of limit elements with the last element containing the rest of string.

If the limit parameter is negative, all components except the last -limit are returned. If the limit parameter is zero, then this is treated as 1.

Returns

\Hazaar\Model\ChildArray
implode()
implode($glue) : string
ChildArray implementation of the implode function

Parameters

$gluemixed

The delimeter. Defaults to an empty string.

Returns

string
jsonSerialize()
jsonSerialize()
key()
key()
next()
next()
offsetExists()
offsetExists($offset)

Parameters

$offset

No description

offsetGet()
offsetGet($offset)

Parameters

$offset

No description

offsetSet()
offsetSet($offset, $value)

Parameters

$offset

No description

$value

No description

offsetUnset()
offsetUnset($offset)

Parameters

$offset

No description

rewind()
rewind()
toArray()
toArray()
valid()
valid()