Download the PHP package abbasghasemi/collection without Composer
On this page you can find all versions of the php package abbasghasemi/collection. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Table of contents
Download abbasghasemi/collection
More information about abbasghasemi/collection
Files in abbasghasemi/collection
Download abbasghasemi/collection
More information about abbasghasemi/collection
Files in abbasghasemi/collection
Vendor abbasghasemi
Package collection
Short Description A collection of complete tools for working with PHP arrays.
License MIT
Package collection
Short Description A collection of complete tools for working with PHP arrays.
License MIT
Please rate this library. Is it a good library?
Informations about the package collection
abbasghasemi/collection
A PHP library for work with arrays
Powerful
- Support List, Map, Set, Stack, Queue, Object ...
- Functional (indexOf, map, where, reduce, first, firstOrNull firstWhere, ...)
- Type generic documentation
- Collections class for generate & filled List
Collections::filled(int $length, mixed $element)
- The ability to enforce maps and lists to accept a specific type
Installation
The preferred of installation is via Composer. Run the following
command to install the package and add it as a requirement to your project's
composer.json
:
Array example
Map example
Arrays class
Class | ArrayList | MutableArrayList | ArraySet | MutableArraySet |
---|---|---|---|---|
Editable | ❌ | ✅ | ❌ | ✅ |
Repeatable | ✅ | ✅ | ❌ | ❌ |
Iterator | ✅ | ✅ | ✅ | ✅ |
Countable | ✅ | ✅ | ✅ | ✅ |
Class methods
Method | ArrayList | MutableArrayList | ArraySet | MutableArraySet |
---|---|---|---|---|
forward | ✅ | ✅ | ✅ | ✅ |
back | ✅ | ✅ | ✅ | ✅ |
size | ✅ | ✅ | ✅ | ✅ |
isEmpty | ✅ | ✅ | ✅ | ✅ |
isNotEmpty | ✅ | ✅ | ✅ | ✅ |
contains | ✅ | ✅ | ✅ | ✅ |
toArray | ✅ | ✅ | ✅ | ✅ |
forEach | ✅ | ✅ | ✅ | ✅ |
first | ✅ | ✅ | ✅ | ✅ |
firstOrNull | ✅ | ✅ | ✅ | ✅ |
last | ✅ | ✅ | ✅ | ✅ |
lastOrNull | ✅ | ✅ | ✅ | ✅ |
get | ✅ | ✅ | ✅ | ✅ |
getRange | ✅ | ✅ | ✅ | ✅ |
take | ✅ | ✅ | ✅ | ✅ |
firstWhere | ✅ | ✅ | ✅ | ✅ |
where | ✅ | ✅ | ✅ | ✅ |
lastWhere | ✅ | ✅ | ✅ | ✅ |
reduce | ✅ | ✅ | ✅ | ✅ |
indexOf | ✅ | ✅ | ✅ | ✅ |
lastIndexOf | ✅ | ✅ | ✅ | ✅ |
indexWhere | ✅ | ✅ | ✅ | ✅ |
lastIndexWhere | ✅ | ✅ | ✅ | ✅ |
join | ✅ | ✅ | ✅ | ✅ |
fillRange | ❌ | ✅ | ❌ | ❌ |
update | ❌ | ✅ | ❌ | ✅ |
reversed | ❌ | ✅ | ❌ | ✅ |
shuffle | ❌ | ✅ | ❌ | ✅ |
add | ❌ | ✅ | ❌ | ✅ |
addAll | ❌ | ✅ | ❌ | ✅ |
insert | ❌ | ✅ | ❌ | ✅ |
insertAll | ❌ | ✅ | ❌ | ✅ |
remove | ❌ | ✅ | ❌ | ✅ |
removeFirst | ❌ | ✅ | ❌ | ✅ |
removeLast | ❌ | ✅ | ❌ | ✅ |
removeRange | ❌ | ✅ | ❌ | ✅ |
removeWhere | ❌ | ✅ | ❌ | ✅ |
sort | ❌ | ✅ | ❌ | ✅ |
clear | ❌ | ✅ | ❌ | ✅ |
Maps class
Class | StringMap | MutableStringMap | InsensitiveMap | MutableInsensitiveMap | ObjectMap | MutableObjectMap |
---|---|---|---|---|---|---|
Editable | ❌ | ✅ | ❌ | ✅ | ❌ | ✅ |
Repeatable | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
Iterator | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
Countable | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
Insensitive | ❌ | ❌ | ✅ | ✅ | - | - |
Object key | ❌ | ❌ | ❌ | ❌ | ✅ | ✅ |
Class methods
Method | StringMap | MutableStringMap | InsensitiveMap | MutableInsensitiveMap | ObjectMap | MutableObjectMap |
---|---|---|---|---|---|---|
size | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
isEmpty | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
isNotEmpty | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
forEach | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
containsKey | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
containsValue | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
keys | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
values | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
mutableValues | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
entries | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
entryKey | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
get | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
get syntax [key] | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
toMap | ✅ | ✅ | ✅ | ✅ | ❌ | ❌ |
put | ❌ | ✅ | ❌ | ✅ | ❌ | ✅ |
set syntax [key] = value | ❌ | ✅ | ❌ | ✅ | ❌ | ✅ |
putIfAbsent | ❌ | ✅ | ❌ | ✅ | ❌ | ✅ |
putAll | ❌ | ✅ | ❌ | ✅ | ❌ | ✅ |
update | ❌ | ✅ | ❌ | ✅ | ❌ | ✅ |
updateKey | ❌ | ✅ | ❌ | ✅ | ❌ | ✅ |
replace | ❌ | ✅ | ❌ | ✅ | ❌ | ✅ |
merge | ❌ | ✅ | ❌ | ✅ | ❌ | ✅ |
remove | ❌ | ✅ | ❌ | ✅ | ❌ | ✅ |
removeWhere | ❌ | ✅ | ❌ | ✅ | ❌ | ✅ |
Collections class
Static method | Description |
---|---|
filled | Collections::filled(int $length, mixed $element, ?string $type = null): ArrayList |
generate | Collections::generate(int $length, callback $callback, ?string $type = null): ArrayList |
of | Collections::of(mixed ...$elements): ArrayList |
typeOf | Collections::typeOf(string $type, mixed ...$elements): ArrayList |
mutableFilled | Collections::filled(int $length, mixed $element, ?string $type = null): MutableArrayList |
mutableGenerate | Collections::generate(int $length, callback $callback, ?string $type = null): MutableArrayList |
mutableOf | Collections::of(mixed ...$elements): MutableArrayList |
mutableTypeOf | Collections::mutableTypeOf(string $type, mixed ...$elements): MutableArrayList |
toArrayList | Collections::toArrayList(Collection $collection): ArrayList |
toMutableArrayList | Collections::toMutableArrayList(Collection $collection): MutableArrayList |
toArraySet | Collections::toArraySet(Collection $collection): ArraySet |
toMutableArraySet | Collections::toMutableArraySet(Collection $collection): MutableArraySet |
sortAscending | Collections::sortAscending(MutableCollection $collection): void |
sortDescending | Collections::sortDescending(MutableCollection $collection): void |
equals | Collections::equals(?ObjectC $a, ?ObjectC $b): bool |
hashCode | Collections::hashCode(mixed $value): int |
toString | Collections::toString(mixed $value): string |
See also easy-data-model
Creates a data model from array data.
Author & support
This library was created by Abbas Ghasemi.
You can report issues at the GitHub Issue Tracker.
All versions of collection with dependencies
PHP Build Version
Package Version
Requires
php Version
^8.1
The package abbasghasemi/collection contains the following files
Loading the files please wait ....