koine / decorator
Decorator for PHP Objects
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-11-23 13:29:56 UTC
README
Simple decorator base class for PHP.
Code information:
Package information:
Usage
Create an class that extends Koine\Decorator and override only the changed methods in there.
<?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
Installing
Via Composer
Append the lib to your requirements key in your composer.json.
{ // composer.json // [..] require: { // append this line to your requirements "koine/decorator": "dev-master" } }
Alternative install
- Learn composer. You should not be looking for an alternative install. It is worth the time. Trust me ;-)
- Follow this set of instructions
Issues/Features proposals
Here is the issue tracker.
Contributing
Only TDD code will be accepted. Please follow the PSR-2 code standard.
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request
How to run the tests:
phpunit --configuration tests/phpunit.xml
To check the code standard run:
phpcs --standard=PSR2 lib phpcs --standard=PSR2 tests