\EasyWeChat\SupportCollection

Class Collection.

Summary

Methods
Properties
Constants
__construct()
all()
only()
except()
merge()
has()
first()
last()
add()
set()
get()
forget()
toArray()
toJson()
__toString()
jsonSerialize()
serialize()
getIterator()
count()
unserialize()
__get()
__set()
__isset()
__unset()
__set_state()
offsetExists()
offsetUnset()
offsetGet()
offsetSet()
No public properties found
No constants found
No protected methods found
$items
N/A
No private methods found
No private properties found
N/A

Properties

$items

$items : array

The collection data.

Type

array

Methods

__construct()

__construct(mixed  $items = array()) 

set data.

Parameters

mixed $items

all()

all() : array

Return all items.

Returns

array

only()

only(array  $keys) : array

Return specific items.

Parameters

array $keys

Returns

array

except()

except(mixed  $keys) : static

Get all items except for those with the specified keys.

Parameters

mixed $keys

Returns

static

has()

has(string  $key) : boolean

To determine Whether the specified element exists.

Parameters

string $key

Returns

boolean

first()

first() : mixed

Retrieve the first item.

Returns

mixed

last()

last() : boolean

Retrieve the last item.

Returns

boolean

add()

add(string  $key, mixed  $value) 

add the item value.

Parameters

string $key
mixed $value

set()

set(string  $key, mixed  $value) 

Set the item value.

Parameters

string $key
mixed $value

get()

get(string  $key, mixed  $default = null) : mixed

Retrieve item from Collection.

Parameters

string $key
mixed $default

Returns

mixed

forget()

forget(string  $key) 

Remove item form Collection.

Parameters

string $key

toArray()

toArray() : array

Build to array.

Returns

array

toJson()

toJson(integer  $option = JSON_UNESCAPED_UNICODE) : string

Build to json.

Parameters

integer $option

Returns

string

__toString()

__toString() : string

To string.

Returns

string

jsonSerialize()

jsonSerialize() : mixed

(PHP 5 &gt;= 5.4.0)<br/> Specify data which should be serialized to JSON.

Returns

mixed —

data which can be serialized by json_encode, which is a value of any type other than a resource

serialize()

serialize() : string

(PHP 5 &gt;= 5.1.0)<br/> String representation of object.

Returns

string —

the string representation of the object or null

getIterator()

getIterator() : \EasyWeChat\Support\Traversable

(PHP 5 &gt;= 5.0.0)<br/> Retrieve an external iterator.

Returns

\EasyWeChat\Support\Traversable —

An instance of an object implementing Iterator or Traversable

count()

count() : integer

(PHP 5 &gt;= 5.1.0)<br/> Count elements of an object.

Returns

integer —

The custom count as an integer.

The return value is cast to an integer

unserialize()

unserialize(string  $serialized) : mixed|void

(PHP 5 &gt;= 5.1.0)<br/> Constructs the object.

Parameters

string $serialized

The string representation of the object.

Returns

mixed|void

__get()

__get(string  $key) : mixed

Get a data by key.

Parameters

string $key

Returns

mixed

__set()

__set(string  $key, mixed  $value) 

Assigns a value to the specified data.

Parameters

string $key
mixed $value

__isset()

__isset(string  $key) : boolean

Whether or not an data exists by key.

Parameters

string $key

Returns

boolean

__unset()

__unset(string  $key) 

Unsets an data by key.

Parameters

string $key

__set_state()

__set_state() : array

var_export.

Returns

array

offsetExists()

offsetExists(mixed  $offset) : boolean

(PHP 5 &gt;= 5.0.0)<br/> Whether a offset exists.

Parameters

mixed $offset

An offset to check for.

Returns

boolean —

true on success or false on failure. The return value will be casted to boolean if non-boolean was returned

offsetUnset()

offsetUnset(mixed  $offset) 

(PHP 5 &gt;= 5.0.0)<br/> Offset to unset.

Parameters

mixed $offset

The offset to unset.

offsetGet()

offsetGet(mixed  $offset) : mixed

(PHP 5 &gt;= 5.0.0)<br/> Offset to retrieve.

Parameters

mixed $offset

The offset to retrieve.

Returns

mixed —

Can return all value types

offsetSet()

offsetSet(mixed  $offset, mixed  $value) 

(PHP 5 &gt;= 5.0.0)<br/> Offset to set.

Parameters

mixed $offset

The offset to assign the value to.

mixed $value

The value to set.