Documentation

Collection extends AbstractArray
in package

Pop utils array collection class

Tags
category

Pop

author

Nick Sagona, III dev@nolainteractive.com

copyright

Copyright (c) 2009-2024 NOLA Interactive, LLC. (http://www.nolainteractive.com)

license

http://www.popphp.org/license New BSD License

version
2.1.0

Table of Contents

Properties

$data  : mixed
Array data

Methods

__construct()  : mixed
Constructor
__get()  : mixed
Get a value
__isset()  : bool
Is value set
__set()  : static
Magic method to set the property to the value of $this->data[$name]
__unset()  : void
Unset a value
column()  : Collection
Get the values of a column
contains()  : bool
Determine if an item exists in the array
count()  : int
Method to get the count of data in the collection
current()  : mixed
Get the current item of the array
each()  : Collection
Execute a callback over each item
every()  : Collection
Create a new collection from every n-th element
filter()  : Collection
Apply filter to the collection
first()  : mixed
Get the first item of the array
flip()  : Collection
Flip the data in the collection
forPage()  : Collection
Slice the collection for a page
getIterator()  : ArrayIterator
Method to iterate over the array object
has()  : bool
Determine if the key exists
isEmpty()  : bool
Determine if the collection is empty or not
join()  : string
Join the array values into a string
key()  : mixed
Get the key of the current item of the array
keys()  : Collection
Get the keys of the collection data
ksort()  : array<string|int, mixed>
Sort array by keys
ksortDesc()  : static
Sort array by keys, descending
last()  : mixed
Get the last item of the array
map()  : Collection
Apply map to the collection
merge()  : Collection
Merge the collection with the passed data
next()  : mixed
Get the next item of the array
offsetExists()  : bool
ArrayAccess offsetExists
offsetGet()  : mixed
ArrayAccess offsetGet
offsetSet()  : void
ArrayAccess offsetSet
offsetUnset()  : void
ArrayAccess offsetUnset
pop()  : mixed
Get and remove the last item from the collection
push()  : Collection
Push an item onto the end of the collection.
shift()  : mixed
Get and remove the first item from the collection
slice()  : Collection
Slice the collection
sort()  : array<string|int, mixed>
Sort array
sortDesc()  : static
Sort array descending
splice()  : Collection
Splice a portion of the collection
split()  : static
Split a string into an array object
toArray()  : array<string|int, mixed>
Get the values as an array
uksort()  : array<string|int, mixed>
Sort array by user-defined callback using keys
usort()  : static
Sort array by user-defined callback
values()  : Collection
Get the values of the collection data
getDataAsArray()  : array<string|int, mixed>
Method to get data as an array

Properties

Methods

__construct()

Constructor

public __construct([mixed $data = [] ]) : mixed

Instantiate the collection object

Parameters
$data : mixed = []

__get()

Get a value

public __get(string $name) : mixed
Parameters
$name : string

__isset()

Is value set

public __isset(string $name) : bool
Parameters
$name : string
Return values
bool

__set()

Magic method to set the property to the value of $this->data[$name]

public __set([string|null $name = null ][, mixed $value = null ]) : static
Parameters
$name : string|null = null
$value : mixed = null
Return values
static

__unset()

Unset a value

public __unset(string $name) : void
Parameters
$name : string

contains()

Determine if an item exists in the array

public contains(mixed $key[, bool $strict = false ]) : bool
Parameters
$key : mixed
$strict : bool = false
Return values
bool

count()

Method to get the count of data in the collection

public count() : int
Return values
int

current()

Get the current item of the array

public current() : mixed

every()

Create a new collection from every n-th element

public every(int $step[, int $offset = 0 ]) : Collection
Parameters
$step : int
$offset : int = 0
Return values
Collection

filter()

Apply filter to the collection

public filter([callable|null $callback = null ][, int $flag = 0 ]) : Collection
Parameters
$callback : callable|null = null
$flag : int = 0
Return values
Collection

first()

Get the first item of the array

public first() : mixed

forPage()

Slice the collection for a page

public forPage(int $page, int $perPage) : Collection
Parameters
$page : int
$perPage : int
Return values
Collection

getIterator()

Method to iterate over the array object

public getIterator() : ArrayIterator
Return values
ArrayIterator

has()

Determine if the key exists

public has(mixed $key) : bool
Parameters
$key : mixed
Return values
bool

isEmpty()

Determine if the collection is empty or not

public isEmpty() : bool
Return values
bool

join()

Join the array values into a string

public join(string $glue[, string $finalGlue = '' ]) : string
Parameters
$glue : string
$finalGlue : string = ''
Return values
string

key()

Get the key of the current item of the array

public key() : mixed

ksort()

Sort array by keys

public ksort([int $flags = SORT_REGULAR ][, bool $descending = false ]) : array<string|int, mixed>
Parameters
$flags : int = SORT_REGULAR
$descending : bool = false
Return values
array<string|int, mixed>

ksortDesc()

Sort array by keys, descending

public ksortDesc([int $flags = SORT_REGULAR ]) : static
Parameters
$flags : int = SORT_REGULAR
Return values
static

merge()

Merge the collection with the passed data

public merge(mixed $data[, bool $recursive = false ]) : Collection
Parameters
$data : mixed
$recursive : bool = false
Return values
Collection

offsetExists()

ArrayAccess offsetExists

public offsetExists(mixed $offset) : bool
Parameters
$offset : mixed
Return values
bool

offsetGet()

ArrayAccess offsetGet

public offsetGet(mixed $offset) : mixed
Parameters
$offset : mixed

offsetSet()

ArrayAccess offsetSet

public offsetSet(mixed $offset, mixed $value) : void
Parameters
$offset : mixed
$value : mixed

offsetUnset()

ArrayAccess offsetUnset

public offsetUnset(mixed $offset) : void
Parameters
$offset : mixed

pop()

Get and remove the last item from the collection

public pop() : mixed

shift()

Get and remove the first item from the collection

public shift() : mixed

slice()

Slice the collection

public slice(int $offset[, int $length = null ]) : Collection
Parameters
$offset : int
$length : int = null
Return values
Collection

sort()

Sort array

public sort([int $flags = SORT_REGULAR ][, bool $assoc = true ][, bool $descending = false ]) : array<string|int, mixed>
Parameters
$flags : int = SORT_REGULAR
$assoc : bool = true
$descending : bool = false
Return values
array<string|int, mixed>

sortDesc()

Sort array descending

public sortDesc([int $flags = SORT_REGULAR ][, bool $assoc = true ]) : static
Parameters
$flags : int = SORT_REGULAR
$assoc : bool = true
Return values
static

splice()

Splice a portion of the collection

public splice(int $offset[, int|null $length = null ][, mixed $replacement = [] ]) : Collection
Parameters
$offset : int
$length : int|null = null
$replacement : mixed = []
Return values
Collection

split()

Split a string into an array object

public static split(string $string, string $separator[, int $limit = PHP_INT_MAX ]) : static
Parameters
$string : string
$separator : string
$limit : int = PHP_INT_MAX
Return values
static

toArray()

Get the values as an array

public toArray() : array<string|int, mixed>
Return values
array<string|int, mixed>

uksort()

Sort array by user-defined callback using keys

public uksort(mixed $callback) : array<string|int, mixed>
Parameters
$callback : mixed
Return values
array<string|int, mixed>

usort()

Sort array by user-defined callback

public usort(mixed $callback[, bool $assoc = true ]) : static
Parameters
$callback : mixed
$assoc : bool = true
Return values
static

getDataAsArray()

Method to get data as an array

protected getDataAsArray(mixed $data) : array<string|int, mixed>
Parameters
$data : mixed
Return values
array<string|int, mixed>

        
On this page

Search results