PHP Class phpstreams\Collectors

For compatibility reasons, the returned collectors are actuall classes, rather than anonymous classes. This is an implementation detail, and should not be relied upon. The implementing classes may be removed at any point.
Author: Bert Peters ([email protected])
Exibir arquivo Open project: bertptrs/phpstreams Class Usage Examples

Public Methods

Method Description
averaging ( ) : phpstreams\Collector Collector that returns the average of the given elements.
joining ( string $delimiter = "" ) : phpstreams\Collector Get a collector that concatenates all the elements in the stream.
reducing ( mixed $identity, callable $reduction ) : phpstreams\Collector Get a collector that applies the given reduction to the stream.

Private Methods

Method Description
__construct ( ) Hidden constructor, static class.

Method Details

averaging() public static method

The return type of this collector is float, regardless of the type of the stream elements.
public static averaging ( ) : phpstreams\Collector
return phpstreams\Collector

joining() public static method

Get a collector that concatenates all the elements in the stream.
public static joining ( string $delimiter = "" ) : phpstreams\Collector
$delimiter string [optional] A delimiter to insert between elements. Defaults to the empty string.
return phpstreams\Collector

reducing() public static method

Get a collector that applies the given reduction to the stream.
public static reducing ( mixed $identity, callable $reduction ) : phpstreams\Collector
$identity mixed
$reduction callable
return phpstreams\Collector