PHP Trait yii\base\ArrayAccessTrait

Note that ArrayAccessTrait requires the class using it contain a property named data which should be an array. The data will be exposed by ArrayAccessTrait to support accessing the class object like an array.
Since: 2.0
Author: Qiang Xue ([email protected])
Show file Open project: yiisoft/yii2

Public Methods

Method Description
count ( ) : integer Returns the number of data items.
getIterator ( ) : ArrayIterator Returns an iterator for traversing the data.
offsetExists ( mixed $offset ) : boolean This method is required by the interface [[\ArrayAccess]].
offsetGet ( integer $offset ) : mixed This method is required by the interface [[\ArrayAccess]].
offsetSet ( integer $offset, mixed $item ) This method is required by the interface [[\ArrayAccess]].
offsetUnset ( mixed $offset ) This method is required by the interface [[\ArrayAccess]].

Method Details

count() public method

This method is required by Countable interface.
public count ( ) : integer
return integer number of data elements.

getIterator() public method

This method is required by the SPL interface [[\IteratorAggregate]]. It will be implicitly called when you use foreach to traverse the collection.
public getIterator ( ) : ArrayIterator
return ArrayIterator an iterator for traversing the cookies in the collection.

offsetExists() public method

This method is required by the interface [[\ArrayAccess]].
public offsetExists ( mixed $offset ) : boolean
$offset mixed the offset to check on
return boolean

offsetGet() public method

This method is required by the interface [[\ArrayAccess]].
public offsetGet ( integer $offset ) : mixed
$offset integer the offset to retrieve element.
return mixed the element at the offset, null if no element is found at the offset

offsetSet() public method

This method is required by the interface [[\ArrayAccess]].
public offsetSet ( integer $offset, mixed $item )
$offset integer the offset to set element
$item mixed the element value

offsetUnset() public method

This method is required by the interface [[\ArrayAccess]].
public offsetUnset ( mixed $offset )
$offset mixed the offset to unset element