jedibc/decorator-stack
Composer 安装命令:
composer require jedibc/decorator-stack
包简介
A simple tool for stacking decorators
关键字:
README 文档
README
A simple tool for stacking decorators.
Installation
The recommended way to install the library is through Composer. Require the jedibc/decorator-stack package into your composer.json file:
{
"require": {
"jedibc/decorator-stack": "@stable"
}
}
Usage
Currently, if you want to decorate an object, you'll have to do something like this :
$decoratedObject = new Foo\Bar\Decorator1( new Foo\Bar\Decorator2( new Foo\Bar\Decorator3( new ObjectToDecorate() ), [$someConstuctorArgument]) );
The more decorators you have, the more ugly your code become.
With DecoratorStack, you can simplify it :
$stack = (new DecoratorStack\Builder('Foo\Bar\DummyInterface')) ->push('Foo\Bar\Decorator1') ->push('Foo\Bar\Decorator2', [$someConstuctorArgument]) ->push('Foo\Bar\Decorator3'); $decoratedObject = $stack->resolve(new ObjectToDecorate())
Each decorator and the object to decorate must implement the Foo\Bar\DummyInterface (or it can be extending an abstract class).
Inspiration
License
DecoratorStack is released under the MIT License. See the bundled LICENSE file for details.
统计信息
- 总下载量: 4.58k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2015-02-14