Download the PHP package carlosv2/funnel without Composer
On this page you can find all versions of the php package carlosv2/funnel. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download carlosv2/funnel
More information about carlosv2/funnel
Files in carlosv2/funnel
Informations about the package funnel
Funnel
Little testing repositories enhancer.
This project aims to provide quick and easy filtering capabilities to everzet/persisted-objects.
Usage
You just need to decorate the testing repository with carlosV2\Funnel\Funnel
. For example:
Funnel also implements Everzet\PersistedObjects\Repository
so you don't lose any feature
and yet you gain some more instead:
- findAll(): Returns an array with all the objects. This is an alias for
getAll
. - findBy(callable): Returns an array with all the matching objects. Empty array is returned if none is found.
- findOneBy(callable): Returns the first matching object or null if none is found.
- countBy(callable): Returns an integer representing the number of matching objects.
For example:
In addition, Funnel provides some generic filters that can be used to speed up development:
- AllOfFilter
- AnyOfFilter
- MethodFilter
- MethodsFilter
- PropertyFilter
- PropertiesFilter
- TypeFilter
- BeingFilter
- HavingFilter
Those filters can be used by composing a new method applying the following rule (where "Not" is optional):
For example:
- findByProperty(...): Finds all the objects that have the given property and value.
- findOneByMethod(...): Finds the first object that matches the given method and value.
- countByNotType(...): Counts all the objects that don't have the given type.
If none of the provided filters match your requirements, you can also add your own filters to Funnel to make them available when composing new methods.
Feel free to create a pull request with your own generic filters! :)
Alternatively, you can decorate an array in order to provide the Funnel API on top of it. For example:
Install
Open a command console, enter your project directory and execute the following command to download the latest stable version of this project:
This command requires you to have Composer installed globally, as explained in the installation chapter of the Composer documentation.
All versions of funnel with dependencies
everzet/persisted-objects Version ^1.0
carlosv2/communism Version ^1.2.2