ebanx/stream

A library to help working with streams of data in PHP

2.0.0 2024-01-26 11:31 UTC

This package is not auto-updated.

Last update: 2024-04-05 12:22:16 UTC


README

Why Stream?

Stream is a neat little library which should help you working with stream of data in PHP. It add methods to help you transform, reduce, and collect data.

Is it stable?

Well, Stream is used by EBANX to process over 17 millions requests per day. So it should be stable enough. But, any problems with it please open an issue or better yet, create a PR to fix it.

Example

Here is an example of how to use it. More examples can be found in the library test.

use EBANX\Stream\Stream;

$result = Stream::rangeInt(0, 10)
    ->map(function (int $value): int {
        return $value ** 2;
    })
    ->filter(function (int $value): bool {
        return $value % 2 === 0;
    })
    ->collect();

Installation

Install the library with Composer by running

composer require ebanx/stream

Licensing

We are distributing it using the permissive MIT license. Feel free to do whatever you want with it.