Collection
class Collection implements CollectionInterface, Countable, ArrayAccess, IteratorAggregate
Collection base class
Properties
protected array | $data | Collection items data |
Methods
Constructor
Create colleciton
Create colection form json file
Return iterator
Return true if key exists in collection
Return true if key exists in collection
Union arrays
Replace array
Get item
Set item
Remove item
Remove item
Remove empy items
Return collection items count.
Set bool value
Set item value by path
Merge collection items
Merge all collection items
Set item value in collection
Add item to collection
Push value to collection
Add value to begining of collection array
Set collection data
Slice collecion by keys
Return collection array
Return true if key exists and value not empty in collection
Get collection item
Get value from collection
Get boolean value
Get text value
Get int value
Get float value
Return array values
Clear collection data
Clone object
Get value
Set value
Get value by path
Add value
Get collection items
Details
at line 34
__construct(array $data = [])
Constructor
at line 45
static Collection
create(array $data)
Create colleciton
at line 58
static Collection
createFromFile(string $fileName, string|null $root = null, array|null $vars = null)
Create colection form json file
at line 73
ArrayIterator
getIterator()
Return iterator
at line 84
bool
has(string $key)
Return true if key exists in collection
at line 95
bool
offsetExists(string $key)
Return true if key exists in collection
at line 106
Collection
union(array $data)
Union arrays
at line 119
Collection
replace(array $replacement)
Replace array
at line 132
mixed
offsetGet(string $key)
Get item
at line 144
void
offsetSet(string $key, mixed $value)
Set item
at line 155
void
offsetUnset(string $key)
Remove item
at line 166
Collection
remove(string $key)
Remove item
at line 178
void
removeEmptyItems()
Remove empy items
at line 190
integer
count()
Return collection items count.
at line 202
void
setBooleanValue(string $path, integer|string $value)
Set bool value
at line 221
void
setValue(string $path, mixed $value)
Set item value by path
at line 234
void
merge(string $key, array $data, bool $recursive = false)
Merge collection items
at line 249
void
mergeItems(array $data, bool $recursive = false)
Merge all collection items
at line 261
Collection
set(string $key, mixed $value)
Set item value in collection
at line 275
void
add(string $key, mixed $value)
Add item to collection
at line 292
bool
push(string $key, mixed $value, string|null $subKey = null)
Push value to collection
at line 319
bool
prepend(string $key, mixed $value, string|null $subKey = null)
Add value to begining of collection array
at line 343
Collection
withData(array $data)
Set collection data
at line 356
array
slice(array|string $keys)
Slice collecion by keys
at line 366
array
toArray()
Return collection array
at line 377
bool
isEmpty(string $key)
Return true if key exists and value not empty in collection
at line 388
Collection
getCollection(string $key)
Get collection item
at line 400
mixed
get(string $key, mixed $default = null)
Get value from collection
at line 412
bool
getBool(string $key, bool|null $default = null)
Get boolean value
at line 424
string|null
getString(string $key, string|null $default = null)
Get text value
at line 438
int|null
getInt(string $key, int|null $default = null)
Get int value
at line 452
float|null
getFloat(string $key, float|null $default = null)
Get float value
at line 466
array
getArray(string $key, mixed $default = null)
Return array values
at line 478
void
clear()
Clear collection data
at line 488
Collection
copy()
Clone object
at line 499
mixed
__get(string $key)
Get value
at line 510
__set(string $key, mixed $value)
Set value
at line 522
mixed
getByPath(string $path, mixed $default = null)
Get value by path
at line 536
bool
addField(string $path, mixed $value)
Add value
at line 555
array
getItems()
Get collection items