Download the PHP package remotelyliving/php-collection without Composer
On this page you can find all versions of the php package remotelyliving/php-collection. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download remotelyliving/php-collection
More information about remotelyliving/php-collection
Files in remotelyliving/php-collection
Package php-collection
Short Description An immutable collection object for object oriented set operations
License MIT
Informations about the package php-collection
php-collection
A lightweight, immutable collection object for set operations
Use Cases
So there is already a really nice collection library out there. I wanted to write my own for two reasons.
- I needed less than half of what it offered.
- It's fun! 2.1 Libraries that load themselves globally as level functions are evil
But also,
If you're tired of using arrays everywhere, this might be for you. If you're jealous of JavaScript's really gorgeous array and object API, this might be for you If the mutability and utter chaos of passing an array around scares you, this might be for you
Installation
Usage
Collect::collect
Collections can be sets of numbers, strings, or objects. No arrays allowed. We don't want to get into multi dimensional madness.
Collection::later
We can create collections that don't don't fill up until we want something from them.
Collection::fill
We can create a prefilled collection
Collection::fromString
We can create a collection from a delineated string
Collection Set Methods
Now to the good stuff! All evaluation or operating methods that take a callable always pass in the value first, then the key. Below is the whole object API. It provides a lot hopefully without overstepping.
You can loop over it just like an array safely. It's \Traversable
and iterable
You can also safely serialize()
and json_encode()
it.
All versions of php-collection with dependencies
ext-json Version *