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
Afficher le fichier Open project: Webiny/Framework Class Usage Examples

Protected Properties

Свойство Type Description
$value Current array.

Méthodes publiques

Méthode 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 méthode

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 méthode

Get key
public __get ( $name )
$name

__set() public méthode

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

__toString() public méthode

To string implementation.
public __toString ( ) : mixed
Résultat mixed String 'Array'.

count() public méthode

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

countValues() public méthode

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

first() public méthode

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

getIterator() public méthode

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

keys() public méthode

Get only the keys of current array.
public keys ( ) : ArrayObject
Résultat ArrayObject An ArrayObject containing only the keys of current array.

last() public méthode

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

offsetExists() public méthode

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

An offset to check for.

Résultat boolean true on success or false on failure.

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

offsetGet() public méthode

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

The offset to retrieve.

Résultat mixed Can return all value types.

offsetSet() public méthode

(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.

Résultat void

offsetUnset() public méthode

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

The offset to unset.

Résultat void

sum() public méthode

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

values() public méthode

Get only the values of current array.
public values ( ) : ArrayObject
Résultat ArrayObject An ArrayObject containing only the values of current array.

Property Details

$value protected_oe property

Current array.
protected $value