The stream.php library is a PHP implementation of collection query API similar to Java Stream API and .NET Linq.
composer require hunts/stream.php
Description: Instantiate a new Stream object
use Hunts\Stream;
...
$stream = Stream::from([$user1, $user2, $user3]);
Description: Instantiate a new NumberStream object
use Hunts\Stream;
...
$stream = NumberStream::from([1, 2, 3]);
Description: Instantiate a new Stream object via global function: stream() or number_stream()
$stream = stream([$user1, $user2, $user3]);
$stream = number_stream([1, 2, 3]);