PHP Class Webiny\Component\StdLib\StdObject\ArrayObject\ArrayObject

This is a helper class for working with arrays.
Inheritance: extends Webiny\Component\StdLib\StdObject\AbstractStdObject, implements IteratorAggregate, implements ArrayAccess, implements Countable, use trait ManipulatorTrait, use trait ValidatorTrait
Show file Open project: Webiny/Framework Class Usage Examples

Protected Properties

Property Type Description
$value Current array.

Public Methods

Method Description
__construct ( null | array | ArrayObject | ArrayAccess $array = null, null | array $values = null ) Constructor.
__get ( $name ) Get key
__set ( $name, $value ) Set array object value
__toString ( ) : mixed To string implementation.
count ( ) : integer Get the number of elements inside the array.
countValues ( ) : ArrayObject Counts the occurrences of the same array values and groups them into an associate array.
first ( ) : StringObject | ArrayObject | StdObjectWrapper Get the first element in the array.
getIterator ( ) : Traversable (PHP 5 >= 5.0.0)
Retrieve an external iterator
keys ( ) : ArrayObject Get only the keys of current array.
last ( ) : StringObject | ArrayObject | StdObjectWrapper Get the last element in the array.
offsetExists ( mixed $offset ) : boolean (PHP 5 >= 5.0.0)
Whether a offset exists
offsetGet ( mixed $offset ) : mixed (PHP 5 >= 5.0.0)
Offset to retrieve
offsetSet ( mixed $offset, mixed $value ) : void (PHP 5 >= 5.0.0)
Offset to set
offsetUnset ( mixed $offset ) : void (PHP 5 >= 5.0.0)
Offset to unset
sum ( ) : number Get the sum of all elements inside the array.
values ( ) : ArrayObject Get only the values of current array.

Method Details

__construct() public method

Set standard object value.
public __construct ( null | array | ArrayObject | ArrayAccess $array = null, null | array $values = null )
$array null | array | ArrayObject | ArrayAccess Array or ArrayAccess from which to create an ArrayObject.
$values null | array Array of values that will be combined with $array. See http://www.php.net/manual/en/function.array-combine.php for more info. $array param is used as key array.

__get() public method

Get key
public __get ( $name )
$name

__set() public method

Set array object value
public __set ( $name, $value )
$name
$value

__toString() public method

To string implementation.
public __toString ( ) : mixed
return mixed String 'Array'.

count() public method

Get the number of elements inside the array.
public count ( ) : integer
return integer Number of elements inside the current array.

countValues() public method

NOTE: This function can only count array values that are type of STRING of INTEGER.
public countValues ( ) : ArrayObject
return ArrayObject An ArrayObject containing the array values as keys and number of their occurrences as values.

first() public method

If the element is array, ArrayObject is returned, else StringObject is returned.
public first ( ) : StringObject | ArrayObject | StdObjectWrapper
return Webiny\Component\StdLib\StdObject\StringObject\StringObject | ArrayObject | StdObjectWrapper The first element in the array.

getIterator() public method

(PHP 5 >= 5.0.0)
Retrieve an external iterator
public getIterator ( ) : Traversable
return Traversable An instance of an object implementing Iterator or Traversable

keys() public method

Get only the keys of current array.
public keys ( ) : ArrayObject
return ArrayObject An ArrayObject containing only the keys of current array.

last() public method

If the element is array, ArrayObject is returned, else StringObject is returned.
public last ( ) : StringObject | ArrayObject | StdObjectWrapper
return Webiny\Component\StdLib\StdObject\StringObject\StringObject | ArrayObject | StdObjectWrapper The last element in the array.

offsetExists() public method

(PHP 5 >= 5.0.0)
Whether a offset exists
public offsetExists ( mixed $offset ) : boolean
$offset mixed

An offset to check for.

return boolean true on success or false on failure.

The return value will be casted to boolean if non-boolean was returned.

offsetGet() public method

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

The offset to retrieve.

return mixed Can return all value types.

offsetSet() public method

(PHP 5 >= 5.0.0)
Offset to set
public offsetSet ( mixed $offset, mixed $value ) : void
$offset mixed

The offset to assign the value to.

$value mixed

The value to set.

return void

offsetUnset() public method

(PHP 5 >= 5.0.0)
Offset to unset
public offsetUnset ( mixed $offset ) : void
$offset mixed

The offset to unset.

return void

sum() public method

Get the sum of all elements inside the array.
public sum ( ) : number
return number The sum of all elements from within the current array.

values() public method

Get only the values of current array.
public values ( ) : ArrayObject
return ArrayObject An ArrayObject containing only the values of current array.

Property Details

$value protected property

Current array.
protected $value