Download the PHP package temkaa/collections without Composer
On this page you can find all versions of the php package temkaa/collections. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download temkaa/collections
More information about temkaa/collections
Files in temkaa/collections
Package collections
Short Description These are simple array and object collections that provide convenient methods to manipulate them.
License MIT
Informations about the package collections
Simple Collections
This project offers a collection that provide convenient methods to manipulate your data.
Installation:
Quickstart
Functionality
addElement(mixed $value, mixed $key = null): self
Adds a new element to collection.
chunk(int $size): list<CollectionInterface<int|string, mixed>>
Chunks elements in collection by given size.
count(): int
Returns count of elements in Collection.
each(callable $callback): CollectionInterface
Executes provided callback on each collection element. If false is returned from callback, iteration stops.
filter(FilterInterface $filter): CollectionInterface
Filters the collection with provided callback.
firstElement(): mixed
Returns first element from collection, null
if collection is empty.
firstKey(): mixed
Returns first key from collection, null
if collection is empty.
hasElement(mixed $value): bool
Returns true if element is found, false otherwise.
hasKey(mixed $key): bool
Returns true if key is found, false otherwise.
empty(): bool
Returns true if collection is empty, false otherwise.
lastElement(): mixed
Returns last element of collection, null if collection is empty.
lastKey(): mixed
Returns last key of collection, null if collection is empty.
map(callable $callback): Collection
Creates new collection from provided callback.
merge(CollectionInterface $collection, bool $recursive = false): CollectionInterface
Merges two collections with each other.
removeElement(mixed $value): self
Removes provided element from collection or silently does nothing if element does not exist.
removeKey(mixed $key): self
Removes provided key from collection or silently does nothing if key does not exist.
slice(int $offset, ?int $length = null): CollectionInterface
Slices collection from given offset with provided length. If length is not defined - gets all elements from given offset.
toArray(): array
Returns collection elements.
sort(Sort $sort): CollectionInterface
Sorts collection by provided directions by path or just values if array is an array of scalars.
unique(array|string|null $path = null): CollectionInterface
Returns unique elements by provided path or just unique array by values.