Sections

Class Phalcon\Collection

Source on GitHub

Namespace Phalcon   Uses ArrayAccess, ArrayIterator, Countable, IteratorAggregate, JsonSerializable, Serializable, Traversable   Implements ArrayAccess, Countable, IteratorAggregate, JsonSerializable, Serializable

Phalcon\Collection is a supercharged object oriented array. It implements ArrayAccess, Countable, IteratorAggregate, JsonSerializable, Serializable

It can be used in any part of the application that needs collection of data Such implementations are for instance accessing globals $_GET, $_POST etc.

Properties

/**
 * @var array
 */
protected data;

/**
 * @var bool
 */
protected insensitive = true;

/**
 * @var array
 */
protected lowerKeys;

Methods

public function __construct( array $data = [], bool $insensitive = bool );

Collection constructor.

public function __get( string $element ): mixed;

Magic getter to get an element from the collection

public function __isset( string $element ): bool;

Magic isset to check whether an element exists or not

public function __set( string $element, mixed $value ): void;

Magic setter to assign values to an element

public function __unset( string $element ): void;

Magic unset to remove an element from the collection

public function clear(): void;

Clears the internal collection

public function count(): int;

Count elements of an object. See count

public function get( string $element, mixed $defaultValue = null ): mixed;

Get the element from the collection

public function getIterator(): Traversable;

Returns the iterator of the class

public function has( string $element ): bool;

Get the element from the collection

public function init( array $data = [] ): void;

Initialize internal array

public function jsonSerialize(): array;

Specify data which should be serialized to JSON See jsonSerialize

public function offsetExists( mixed $element ): bool;

Whether a offset exists See offsetExists

public function offsetGet( mixed $element );

Offset to retrieve See offsetGet

public function offsetSet( mixed $element, mixed $value ): void;

Offset to set See offsetSet

public function offsetUnset( mixed $element ): void;

Offset to unset See offsetUnset

public function remove( string $element ): void;

Delete the element from the collection

public function serialize(): string;

String representation of object See serialize

public function set( string $element, mixed $value ): void;

Set an element in the collection

public function toArray(): array;

Returns the object in an array format

public function toJson( int $options = int ): string;

Returns the object in a JSON format

The default string uses the following options for json_encode

JSON_HEX_TAG, JSON_HEX_APOS, JSON_HEX_AMP, JSON_HEX_QUOT, JSON_UNESCAPED_SLASHES

See rfc4627

public function unserialize( mixed $serialized ): void;

Constructs the object See unserialize

protected function setData( string $element, mixed $value ): void;

Internal method to set data

Class Phalcon\Collection\Exception

Source on GitHub

Namespace Phalcon\Collection   Uses Throwable   Extends \Phalcon\Exception   Implements Throwable

Exceptions for the Collection object

Class Phalcon\Collection\ReadOnly

Source on GitHub

Namespace Phalcon\Collection   Uses Phalcon\Collection, Phalcon\Collection\Exception   Extends Collection

Phalcon\Collection\ReadOnly is a read only Collection object

Methods

public function remove( string $element ): void;

Delete the element from the collection

public function set( string $element, mixed $value ): void;

Set an element in the collection