Skip to main content

GV\Collection

A generic Collection base class.

Source: stubs/gravityview.php:444

Details​

  • Kind: class
  • Namespace: GV

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: stubs/gravityview.php:459

clear()​

public function clear()

Clear this collection.

Returns​

  • void

Since: 2.0

Source: stubs/gravityview.php:469

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: stubs/gravityview.php:481

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: stubs/gravityview.php:491

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: stubs/gravityview.php:501

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: stubs/gravityview.php:511

count()​

public function count()

Returns the count of the objects in this collection.

Returns​

  • int — The size of this collection.

Since: 2.0

Source: stubs/gravityview.php:521