PHP Класс Webiny\Component\StdLib\StdObject\ArrayObject\ArrayObject

This is a helper class for working with arrays.
Наследование: extends Webiny\Component\StdLib\StdObject\AbstractStdObject, implements IteratorAggregate, implements ArrayAccess, implements Countable, use trait ManipulatorTrait, use trait ValidatorTrait
Показать файл Открыть проект Примеры использования класса

Защищенные свойства (Protected)

Свойство Тип Описание
$value Current array.

Открытые методы

Метод Описание
__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.

Описание методов

__construct() публичный Метод

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() публичный Метод

Get key
public __get ( $name )
$name

__set() публичный Метод

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

__toString() публичный Метод

To string implementation.
public __toString ( ) : mixed
Результат mixed String 'Array'.

count() публичный Метод

Get the number of elements inside the array.
public count ( ) : integer
Результат integer Number of elements inside the current array.

countValues() публичный Метод

NOTE: This function can only count array values that are type of STRING of INTEGER.
public countValues ( ) : ArrayObject
Результат ArrayObject An ArrayObject containing the array values as keys and number of their occurrences as values.

first() публичный Метод

If the element is array, ArrayObject is returned, else StringObject is returned.
public first ( ) : StringObject | ArrayObject | StdObjectWrapper
Результат Webiny\Component\StdLib\StdObject\StringObject\StringObject | ArrayObject | StdObjectWrapper The first element in the array.

getIterator() публичный Метод

(PHP 5 >= 5.0.0)
Retrieve an external iterator
public getIterator ( ) : Traversable
Результат Traversable An instance of an object implementing Iterator or Traversable

keys() публичный Метод

Get only the keys of current array.
public keys ( ) : ArrayObject
Результат ArrayObject An ArrayObject containing only the keys of current array.

last() публичный Метод

If the element is array, ArrayObject is returned, else StringObject is returned.
public last ( ) : StringObject | ArrayObject | StdObjectWrapper
Результат Webiny\Component\StdLib\StdObject\StringObject\StringObject | ArrayObject | StdObjectWrapper The last element in the array.

offsetExists() публичный Метод

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

An offset to check for.

Результат boolean true on success or false on failure.

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

offsetGet() публичный Метод

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

The offset to retrieve.

Результат mixed Can return all value types.

offsetSet() публичный Метод

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

Результат void

offsetUnset() публичный Метод

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

The offset to unset.

Результат void

sum() публичный Метод

Get the sum of all elements inside the array.
public sum ( ) : number
Результат number The sum of all elements from within the current array.

values() публичный Метод

Get only the values of current array.
public values ( ) : ArrayObject
Результат ArrayObject An ArrayObject containing only the values of current array.

Описание свойств

$value защищенное свойство

Current array.
protected $value