paulhenri-l / php-abstract-decorator
php-abstract-decorator
1.0.0
2021-10-02 17:25 UTC
Requires
- php: ^7.3|^8.0
Requires (Dev)
- ext-mbstring: *
- friendsofphp/php-cs-fixer: ^3.1
- paulhenri-l/php-cs-config: ^1.0
- phpunit/phpunit: ^9.0
- symfony/var-dumper: ^5.3
README
This abstract class helps you in creating decorators for your classes.
Installation
composer require paulhenri-l/php-abstract-decorator
Usage
<?php class Person { public function talk() { return "hello"; } public function name() { return "none"; } } class LoudPerson extends \PaulhenriL\PhpAbstractDecorator\AbstractDecorator { public function talk(){ return mb_strtoupper( $this->decoratedInstance->talk() ); } } $person = new Person; $loudPerson = new LoudPerson($person); $loudPerson->talk(); // HELLO $loudPerson->name(); // none