Documentation

Collection extends Iterator
in package
implements Countable, Products

Class Collection

Base class for product collections

Interfaces, Classes, Traits and Enums

Countable
Products
Interface Products

Table of Contents

$data  : array<string|int, mixed>
The data array
__construct()  : void
Constructor
__get()  : mixed
Getter
__isset()  : bool
Checks if the current key is set
__set()  : self
Setter
__toString()  : string
Exports keys when casting to string
__unset()  : void
Remover
add()  : self
Adds product(s)
append()  : self
Appends single product
clone()  : self
Clones instance
count()  : int
Counts all elements
current()  : mixed
Returns the current element
empty()  : static
Provides empty instance clone
findByKey()  : Product
Finds single product by product EAN/ISBN
first()  : Product
Exports first product
flip()  : static
Reverses product order
get()  : Product
Getter
getIterator()  : ArrayIterator
Get an iterator for the items.
has()  : bool
Checks by key if an element is included
indexOf()  : int|false
Tries to find the index number for the given element
key()  : string
Returns the current key
keyOf()  : string|false
Tries to find the key for the given element
keys()  : array<string|int, mixed>
Returns an array of all keys
last()  : Product
Exports last product
next()  : mixed
Moves the cursor to the next element and returns it
prepend()  : self
Prepends single product
prev()  : mixed
Moves the cursor to the previous element and returns it
remove()  : self
Remover
rewind()  : mixed
Moves the cursor to the first element
set()  : self
Setter
toArray()  : array<string|int, mixed>
Converts products to array
toJson()  : string
Converts products to JSON string
toString()  : string
Converts products to string
valid()  : bool
Checks if the current element is valid
strip()  : string
Helpers

Properties

$data

The data array

public array<string|int, mixed> $data = []

Methods

__construct()

Constructor

public __construct([array<string|int, mixed> $data = [] ]) : void
Parameters
$data : array<string|int, mixed> = []
Tags
array

$data Products

Return values
void

__get()

Getter

public __get(mixed $key) : mixed
Parameters
$key : mixed
Return values
mixed

__isset()

Checks if the current key is set

public __isset(mixed $key) : bool
Parameters
$key : mixed

the key to check

Return values
bool

__set()

Setter

public __set(string $key, mixed $value) : self
Parameters
$key : string
$value : mixed
Return values
self

__toString()

Exports keys when casting to string

public __toString() : string
Return values
string

__unset()

Remover

public __unset(mixed $key) : void
Parameters
$key : mixed
Return values
void

append()

Appends single product

public append(Product $object) : self
Parameters
$object : Product

Product

Return values
self

clone()

Clones instance

public clone() : self
Return values
self

count()

Counts all elements

public count() : int
Return values
int

current()

Returns the current element

public current() : mixed
Return values
mixed

empty()

Provides empty instance clone

public empty() : static
Return values
static

findByKey()

Finds single product by product EAN/ISBN

public findByKey(string $identifier) : Product
Parameters
$identifier : string
Return values
Product

flip()

Reverses product order

public flip() : static
Return values
static

get()

Getter

public get(mixed $key[, mixed $default = null ]) : Product
Parameters
$key : mixed
$default : mixed = null
Return values
Product

getIterator()

Get an iterator for the items.

public getIterator() : ArrayIterator
Return values
ArrayIterator

has()

Checks by key if an element is included

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

indexOf()

Tries to find the index number for the given element

public indexOf(mixed $needle) : int|false
Parameters
$needle : mixed

the element to search for

Return values
int|false

the index (int) of the element or false

key()

Returns the current key

public key() : string
Return values
string

keyOf()

Tries to find the key for the given element

public keyOf(mixed $needle) : string|false
Parameters
$needle : mixed

the element to search for

Return values
string|false

the name of the key or false

keys()

Returns an array of all keys

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

next()

Moves the cursor to the next element and returns it

public next() : mixed
Return values
mixed

prepend()

Prepends single product

public prepend(Product $object) : self
Parameters
$object : Product

Product

Return values
self

prev()

Moves the cursor to the previous element and returns it

public prev() : mixed
Return values
mixed

remove()

Remover

public remove(mixed $key) : self
Parameters
$key : mixed
Return values
self

rewind()

Moves the cursor to the first element

public rewind() : mixed
Return values
mixed

set()

Setter

public set(array<string|int, mixed>|string $key[, Product $value = null ]) : self
Parameters
$key : array<string|int, mixed>|string
$value : Product = null

Product object

Return values
self

toArray()

Converts products to array

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

toJson()

Converts products to JSON string

public toJson() : string
Return values
string

toString()

Converts products to string

public toString() : string
Return values
string

valid()

Checks if the current element is valid

public valid() : bool
Return values
bool

strip()

Helpers

private strip(string $string) : string
Parameters
$string : string
Return values
string

Search results