PHPackages                             team-a/collection - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. team-a/collection

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

team-a/collection
=================

Filtered collections.

2.1.1(6y ago)372MITPHPPHP ^7.4CI failing

Since Feb 3Pushed 6y ago1 watchersCompare

[ Source](https://github.com/team-a-pro/collection)[ Packagist](https://packagist.org/packages/team-a/collection)[ RSS](/packages/team-a-collection/feed)WikiDiscussions master Synced 1w ago

READMEChangelogDependencies (3)Versions (7)Used By (0)

collection
==========

[](#collection)

[![Coverage Status](https://camo.githubusercontent.com/e94cdc2bda7c2484670f9807b08263771e0cf5f19032a7368b316bc0c7dc2cf6/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f7465616d2d612d70726f2f636f6c6c656374696f6e2f62616467652e7376673f6272616e63683d6d6173746572)](https://coveralls.io/github/team-a-pro/collection?branch=master)

TeamA\\Collection is a library of interfaces and traits for filtering and sorting collections.

The library solves performance problems, code duplication, and allows you to design contexts for using collections in separate classes.

It is possible to implement sorting and filtering by many criteria.

Sorting and filtering by many criteria is supported. Filters and sorters are implemented as objects with a set of modifiers. Filters can be joined using the "AND", "OR" logic.

Provides a check for matching the types included in the collection with the types for which filters are implemented.

Requirements
------------

[](#requirements)

- php &gt;= 7.4

Install via Composer
--------------------

[](#install-via-composer)

`composer require team-a/collection:^2.1`

Methods
-------

[](#methods)

### Collection

[](#collection-1)

- sort
- sortReverse
- filter
- filterNotMatched
- first
- firstNotMatched
- last
- lastNotMatched
- has
- isAllMatched
- isEmpty
- hasNot
- count
- countNotMatched
- asArray
- asArrayNotMatched

### Filter chains

[](#filter-chains)

- and
- or
- not

Examples
--------

[](#examples)

For a working example, see tests/Model.

```
