Download the PHP package jeroen/generic-decorator without Composer
On this page you can find all versions of the php package jeroen/generic-decorator. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download jeroen/generic-decorator
More information about jeroen/generic-decorator
Files in jeroen/generic-decorator
Package generic-decorator
Short Description Builder for generic and type safe decorators
License GPL-2.0+
Homepage https://github.com/JeroenDeDauw/GenericDecorator
Informations about the package generic-decorator
Generic Decorator
A builder for generic and type safe PHP decorators.
Usage
This library provides the DecoratorBuilder
class, which follows the
Builder pattern, and
thus is similar in use as PHPUnit's MockBuilder interface.
You construct a new builder by calling DecoratorBuilder::newBuilder
and
passing in the object you want to decorate. Then you can call withBefore
and withAfter
, to define the decorated behaviour. Finally you call
newDecorator
and get the decorated instance.
The callable provided to withBefore
and withAfter
receives all
arguments the decorated method receives.
Missing features / roadmap
- Allow decorating generated decorators (this will fatal error at present)
- Support try-catch, ie for logging decorators
- Provide a way to get the name of the calling method (anyone knows how to do that without crazy debug_backtrace hacks?)
- Test presence of private and protected methods
- Test final class
- Test exceptions
- Test internal calls to public methods
Release notes
0.1.2 (2017-02-06)
- Made installable with PHPUnit Mock Objects 4.x
0.1.1 (2016-08-16)
- Decorating classes with required constructor parameters now works
0.1.0 (2016-07-29)
- Initial release