koine / decorator
PHP对象装饰器
0.9.2
2014-08-29 16:10 UTC
Requires
- koine/core: 0.9.*
Requires (Dev)
- phpunit/phpunit: *
- satooshi/php-coveralls: dev-master
This package is not auto-updated.
Last update: 2024-09-14 12:44:34 UTC
README
PHP简单装饰器基类。
代码信息
包信息
用法
创建一个扩展 Koine\Decorator 并仅覆盖其中更改的方法的类。
<?php class Product { public function getPrice() { return 123.99; } public function getName() { return "Product Name"; } } class ProductDecorator extends \Koine\Decorator { public function getPrice() { return 'US ' . $this->object->getPrice(); } } $product = new Product; $decorator = new ProductDecorator($product); $decorator->getName(); // Product Name $decorator->getPrice(); // US 123.99
安装
通过 Composer
将库添加到您的 composer.json 中的 requirements 键。
{ // composer.json // [..] require: { // append this line to your requirements "koine/decorator": "dev-master" } }
替代安装
问题/功能建议
这里 是问题跟踪器。
贡献
只有通过 TDD 编写的代码将被接受。请遵循 PSR-2 代码规范。
- 分支它
- 创建您的功能分支 (
git checkout -b my-new-feature
) - 提交您的更改 (
git commit -am 'Add some feature'
) - 推送到分支 (
git push origin my-new-feature
) - 创建新的 Pull Request
如何运行测试
phpunit --configuration tests/phpunit.xml
要检查代码规范,请运行
phpcs --standard=PSR2 lib phpcs --standard=PSR2 tests