Class Phalcon\Collection
Source sur GitHub
Namespace |
Phalcon |
|
Uses |
ArrayAccess, ArrayIterator, Countable, IteratorAggregate, JsonSerializable, Phalcon\Collection\CollectionInterface, Phalcon\Helper\Json, Serializable, Traversable |
|
Implements |
ArrayAccess, CollectionInterface, Countable, IteratorAggregate, JsonSerializable, Serializable |
Phalcon\Collection
is a supercharged object oriented array. It implements:
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;
Méthodes
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, string $cast = null ): mixed;
Get the element from the collection
public function getIterator(): Traversable;
Returns the iterator of the class
public function getKeys( bool $insensitive = bool ): array;
public function getValues(): array;
public function has( string $element ): bool;
Determines whether an element is present in 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
Interface Phalcon\Collection\CollectionInterface
Source sur GitHub
Namespace |
Phalcon\Collection |
Phalcon\Collection\CollectionInterface
Interface for Phalcon\Collection class
Méthodes
public function __get( string $element ): mixed;
public function __isset( string $element ): bool;
public function __set( string $element, mixed $value ): void;
public function __unset( string $element ): void;
public function clear(): void;
public function get( string $element, mixed $defaultValue = null, string $cast = null ): mixed;
public function getKeys( bool $insensitive = bool ): array;
public function getValues(): array;
public function has( string $element ): bool;
public function init( array $data = [] ): void;
public function remove( string $element ): void;
public function set( string $element, mixed $value ): void;
public function toArray(): array;
public function toJson( int $options = int ): string;
Class Phalcon\Collection\Exception
Source sur GitHub
Namespace |
Phalcon\Collection |
|
Uses |
Throwable |
|
Extends |
\Phalcon\Exception |
|
Implements |
Throwable |
Exceptions for the Collection object
Class Phalcon\Collection\ReadOnly
Source sur GitHub
Namespace |
Phalcon\Collection |
|
Uses |
Phalcon\Collection |
|
Extends |
Collection |
Phalcon\Collection\ReadOnly is a read only Collection object
Méthodes
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