class SimpleCollection implements CollectionInterface

Collection This class provides a common interface used by many other classes in a Inhere\Library application that manage "collections" of data that must be inspected and/or manipulated

Properties

protected array $data The source data

Methods

make(array|null $items = null)

No description

__construct(array $items = [])

Create new collection

__destruct()

No description

set($key, $value)

Set collection item

$this
add($name, $value)

No description

get(string $key, $default = null)

Get collection item for key

replace(array $items)

Add item to collection

array
gets(array $names)

No description

sets(array $data)

No description

reject(callable $filter)

No description

map(callable $callback)

No description

string
implode(string $char = ',')

No description

array
all()

Get all items in collection

array
toArray()

No description

array
keys()

Get collection keys

bool
has(string $key)

Does this collection have a given key?

mixed
remove($key)

Remove item from collection

clear()

Remove all items from collection

bool
offsetExists(string $key)

Does this collection have a given key?

mixed
offsetGet(string $key)

Get collection item for key

offsetSet(string $key, mixed $value)

Set collection item

mixed|null
offsetUnset(string $key)

Remove item from collection

int
count()

Get number of items in collection

array
jsonSerialize()

No description

string
serialize()

No description

unserialize(string $serialized, bool|array $allowedClasses = false)

No description

getIterator()

Get collection iterator

mixed
__get($name)

No description

__set($name, $value)

No description

__isset($name)

No description

Details

at line 26
static SimpleCollection make(array|null $items = null)

Parameters

array|null $items

Return Value

SimpleCollection

at line 35
__construct(array $items = [])

Create new collection

Parameters

array $items Pre-populate collection with this key-value array

at line 40
__destruct()

at line 55
set($key, $value)

Set collection item

Parameters

$key
$value

at line 67
$this add($name, $value)

Parameters

$name
$value

Return Value

$this

at line 82
get(string $key, $default = null)

Get collection item for key

Parameters

string $key
$default

at line 91
replace(array $items)

Add item to collection

Parameters

array $items

at line 102
array gets(array $names)

Parameters

array $names

Return Value

array

at line 117
SimpleCollection sets(array $data)

Parameters

array $data

Return Value

SimpleCollection

at line 130
SimpleCollection reject(callable $filter)

Parameters

callable $filter

Return Value

SimpleCollection

at line 149
SimpleCollection map(callable $callback)

Parameters

callable $callback

Return Value

SimpleCollection

at line 165
string implode(string $char = ',')

Parameters

string $char

Return Value

string

at line 174
array all()

Get all items in collection

Return Value

array

at line 182
array toArray()

Return Value

array

at line 191
array keys()

Get collection keys

Return Value

array The collection's source data keys

at line 201
bool has(string $key)

Does this collection have a given key?

Parameters

string $key

Return Value

bool

at line 211
mixed remove($key)

Remove item from collection

Parameters

$key

Return Value

mixed

at line 226
clear()

Remove all items from collection

at line 240
bool offsetExists(string $key)

Does this collection have a given key?

Parameters

string $key The data key

Return Value

bool

at line 250
mixed offsetGet(string $key)

Get collection item for key

Parameters

string $key The data key

Return Value

mixed The key's value, or the default value

at line 260
offsetSet(string $key, mixed $value)

Set collection item

Parameters

string $key The data key
mixed $value The data value

at line 270
mixed|null offsetUnset(string $key)

Remove item from collection

Parameters

string $key The data key

Return Value

mixed|null

at line 283
int count()

Get number of items in collection

Return Value

int

at line 295
array jsonSerialize()

Return Value

array

at line 307
string serialize()

Return Value

string

at line 316
unserialize(string $serialized, bool|array $allowedClasses = false)

Parameters

string $serialized
bool|array $allowedClasses

at line 329
ArrayIterator getIterator()

Get collection iterator

Return Value

ArrayIterator

at line 342
mixed __get($name)

Parameters

$name

Return Value

mixed

at line 347
__set($name, $value)

Parameters

$name
$value

at line 352
__isset($name)

Parameters

$name