innmind / stack
Helper to build stacks
1.2.0
2021-02-15 16:02 UTC
Requires
- php: ~7.2|~8.0
Requires (Dev)
- phpunit/phpunit: ~8.0
- vimeo/psalm: ~4.4
This package is auto-updated.
Last update: 2024-12-16 00:12:29 UTC
README
Simple function to stack elements on top of each others. Useful to create object stacks.
Installation
composer require innmind/stack
Usage
use function Innmind\Stack\stack; $decorate = stack( static function(RequestHandler $handler) { return new ValidateRequest($handler); }, static function(RequestHandler $handler) { return new Security($handler); } ); $handler = $decorate(new MyRequestHandler);
The above example is equivalent to:
$handler = new ValidateRequest( new Security( new MyRequestHandler ) );
Note: the classes uses do not exist, they're only meant as an example.