jedibc/decorator-stack 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

jedibc/decorator-stack

Composer 安装命令:

composer require jedibc/decorator-stack

包简介

A simple tool for stacking decorators

README 文档

README

Build Status

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

GitHub 信息

  • Stars: 1
  • Watchers: 1
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-02-14

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固