Download the PHP package bhittani/dispenser without Composer
On this page you can find all versions of the php package bhittani/dispenser. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download bhittani/dispenser
More information about bhittani/dispenser
Files in bhittani/dispenser
Package dispenser
Short Description Dispense entities under a disciplined regime
License MIT
Homepage https://github.com/kamalkhan/dispenser
Informations about the package dispenser
Dispenser
Dispense entities under a disciplined regime.
- Install
- Usage
- Dispenser
- Queue Dispenser
- Stack Dispenser
- Priority Dispenser
- Pipeline Dispenser
- Chain Dispenser
- Using the chain dispenser as an http middleware
- Creating custom/extended dispensers
- Example dispenser implementation
- Changelog
- Testing
- Contributing
- Security
- Credits
- License
Install
You may install this package using composer.
Usage
Dispenser
At its core, the dispenser handles a function call.
Queue Dispenser
A queue dispenser maintains a collection of dispensers in a queue.
Stack Dispenser
A stack dispenser maintains a collection of dispensers in a stack.
Priority Dispenser
A priority dispenser maintains a collection of dispensers in a priority heap.
The rank is directly proportional to the priority value. In the example above, priority value 3 dispenses first, followed by 2, and finally by 1.
Pipeline Dispenser
A pipeline allows piping through dispensers by passing on the result of the previous piped dispenser onto the next piped dispenser.
The iterator dispenser's discipline will be respected. i.e. if we were to use a priority dispenser, the results would vary due to the potential difference in the order of dispensation.
Chain Dispenser
A chain accepts dispensers and work on it as a chain. As opposed to a pipeline, a dispenser within a chain receives a handler to the next dispenser in the chain and can be completely ignored in order to stop further processing of the chain.
Every dispenser's discipline will be respected. i.e. if we were to use a stack dispenser, the results would vary due to the potential difference in the order of dispensation.
Different types of dispensers can be pushed to the same chain.
The fallback dispenser is optional and does not have a final $next parameter because it will be the last dispenser in the chain.
Using the chain dispenser as an http middleware
Due to the powerful discipline of the chain dispenser, we can use it as an http middleware chain.
Creating custom/extended dispensers
Extended dispensers can be created by implementing the Bhittani\Dispenser\DispenserInterface interface. It has only one required method dispense which accepts variadic arguments. This makes it very simple to mix and utilize other dispensers. The power is in your hands.
Example dispenser implementation
The above implementation works as an event subscriber and publisher.
For availability, the
Dispatcheris also available under theBhittani\Dispensernamespace.
Changelog
Please see CHANGELOG for more information on what has changed.
Testing
Contributing
Please see CONDUCT for details.
Security
If you discover any security related issues, please email [email protected] instead of using the issue tracker.
Credits
License
The MIT License (MIT). Please see the License File for more information.