Skip to content

Latest commit

 

History

History
44 lines (31 loc) · 814 Bytes

API.md

File metadata and controls

44 lines (31 loc) · 814 Bytes

API References

Filter

Description: Returns a stream consisting of the elements of this stream that match the given predicate.

Example
// Find users whose first names are "John"
$stream->filter(function(User $user) {
    return $user->getFirstName() === 'John';
});

First

Description: Returns the first element of matched items, or null if the stream is empty.

Example
// Find the first user whose age is 28
$user = $stream->first(function(User $user) {
    return $user->getAge() === 28;
});

Last

Description: Returns the last element of matched items, or null if the stream is empty.

Example
// Find the last user whose age is 28
$user = $stream->last(function(User $user) {
    return $user->getAge() === 28;
});