Skip to main content

GravityKit\GravityView\Data\Collection

A generic Collection base class.

Source: src/Data/Collection.php:16

Details​

  • Kind: class
  • Namespace: GravityKit\GravityView\Data

Properties​

PropertyTypeDescription
$storagearray<T>Main storage for objects in this collection.

Methods​

MethodDescription
add()Add an object to this collection.
clear()Clear this collection.
merge()Merge another collection into here.
all()Returns all the objects in this collection as an an array.
last()Get the last added object.
first()Get the first added object.
count()Returns the count of the objects in this collection.

Method Reference​

add()​

public function add( $value )

Add an object to this collection.

Parameters​

NameTypeDefaultDescription
$valueTThe object to be added.

Returns​

  • void

Since: 2.0

Source: src/Data/Collection.php:31

clear()​

public function clear()

Clear this collection.

Returns​

  • void

Since: 2.0

Source: src/Data/Collection.php:42

merge()​

public function merge( \GV\Collection $collection )

Merge another collection into here.

Parameters​

NameTypeDefaultDescription
$collection\GV\Collection<T>The collection to be merged.

Returns​

  • void

Since: 2.0

Source: src/Data/Collection.php:55

all()​

public function all()

Returns all the objects in this collection as an an array.

Returns​

  • array<T> — The objects in this collection.

Since: 2.0

Source: src/Data/Collection.php:66

last()​

public function last()

Get the last added object.

Returns​

  • T | null — The last item in here, or null if there are none.

Since: 2.0

Source: src/Data/Collection.php:77

first()​

public function first()

Get the first added object.

Returns​

  • T | null — The first item in here, or null if there are none.

Since: 2.0

Source: src/Data/Collection.php:88

count()​

public function count()

Returns the count of the objects in this collection.

Returns​

  • int — The size of this collection.

Since: 2.0

Source: src/Data/Collection.php:99