Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR introduces a couple of useful functions to the Collection class.
The introduced functions are:
fromIterable
- enables users of the collection to construction the collection from an iterable value like iterators, generators, etc.every
- Returns true if given callback returns truthy values for all itemsnone
- Returns true if given callback returns falsy values for all itemssome
- Returns true if given callback returns truthy values on some itemsfirst
- Get the first element of the collection that matches a callback, if given. Throws exception if collection is empty or predicate is never satisfiedfirstOr
- Same as first but returns $fallbackValue if collection is empty or predicate is never satisfiedlast
- Get the last element of the collection that matches a callback, if given. Throws exception if collection is empty or predicate is never satisfiedlastOr
- Same as last but returns $fallbackValue if collection is empty or predicate is never satisfiedisEmpty
- Returns whether the collection is emptyhasItems
- Returns whether the collection has items