Download the PHP package pepegar/streams-php without Composer
On this page you can find all versions of the php package pepegar/streams-php. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download pepegar/streams-php
More information about pepegar/streams-php
Files in pepegar/streams-php
Package streams-php
Short Description A port of the Streams library for Java8. Let's make PHP cooler.
License MIT
Informations about the package streams-php
Streams
Streams is a port of the Streams library for PHP. It makes working with collections super pleasant.
Installation
Just add the following to your composer.json
file:
Usage
An example with the Yii ActiveRecord lib:
Available functions
Even though this library is under active development, the currently available methods are:
map(callable $callback)
As in every functional programming language, map takes a function as argument and applies it to each element in the array, returning a new array with the results.
filter(callable $callback)
takes a function as argument and applies it to each element in the collection. It returns a new collection containing all elements where the callback returned true.
allMatch(callable $predicate)
returns wether all the elements in the stream match the given predicate
anyMatch(callable $predicate)
returns wether any the elements in the stream match the given predicate
concat(Stream $a, Stream $b)
Creates a lazily concatenated stream whose elements are all the elements of the first stream followed by all the elements of the second stream.
count()
returns the count of elements in the stream
distinct()
returns a new stream consisting of the distinct elements of the stream
Hacking
Please, submit your Pull Requests, and make sure that the build passes.