PHPackages                             coapsyfactor/decorator - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. coapsyfactor/decorator

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

coapsyfactor/decorator
======================

PHP Decorator, dynamicly adding methods and properties with proper scope and $this assigned before execution.

40PHP

Since Jan 24Pushed 7y ago1 watchersCompare

[ Source](https://github.com/CoaPsyFactor/decorator)[ Packagist](https://packagist.org/packages/coapsyfactor/decorator)[ RSS](/packages/coapsyfactor-decorator/feed)WikiDiscussions master Synced 2d ago

READMEChangelogDependenciesVersions (1)Used By (0)

### PHP Decorator

[](#php-decorator)

Dynamically add methods on objects with provided proper context and scope when executing.

### Usage

[](#usage)

Class that can be decorated **MUST** use `Decoratable` trait.

`Decoratable` trait relies on magic methods `__call` and `__get`, therefor using them directly is not possible without breaking `Decorator` functionality.

To set custom `__call` and `__get` use `__onCall` and `__onGet` instead.

##### Basic Decoration

[](#basic-decoration)

Add method to some object.

```
