PHPackages                             phpnomad/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. phpnomad/decorator

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

phpnomad/decorator
==================

Assists with implementing decorator patterns.

1.0.0(1y ago)061[1 PRs](https://github.com/phpnomad/decorator/pulls)1MITPHPCI passing

Since Feb 5Pushed 2mo ago2 watchersCompare

[ Source](https://github.com/phpnomad/decorator)[ Packagist](https://packagist.org/packages/phpnomad/decorator)[ Docs](https://github.com/phoenix/core)[ RSS](/packages/phpnomad-decorator/feed)WikiDiscussions main Synced today

READMEChangelog (1)Dependencies (1)Versions (7)Used By (1)

phpnomad/decorator
==================

[](#phpnomaddecorator)

[![Latest Version](https://camo.githubusercontent.com/3cce21397e2a5386f87cf3e7bc39339a47e08ff0a3ce1d12712de7c18abef988/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7068706e6f6d61642f6465636f7261746f722e737667)](https://packagist.org/packages/phpnomad/decorator)[![Total Downloads](https://camo.githubusercontent.com/d52185ade73381f24da65bfa5db578abb6199e9686514929e43fc11e45346189/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f7068706e6f6d61642f6465636f7261746f722e737667)](https://packagist.org/packages/phpnomad/decorator)[![PHP Version](https://camo.githubusercontent.com/79440aecdae7fc70819dc45d293cfe7962c1331e0aa234b7155095eadbebe0f4/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f7068706e6f6d61642f6465636f7261746f722e737667)](https://packagist.org/packages/phpnomad/decorator)[![License](https://camo.githubusercontent.com/9d6e188d39bcba3478fb0c4058c11439b9da60be5d0094f428ad76b4f1602be2/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f7068706e6f6d61642f6465636f7261746f722e737667)](https://packagist.org/packages/phpnomad/decorator)

`phpnomad/decorator` is a small helper for writing decorator classes in PHP. It ships a single trait, `WithDecoratedInstance`, that forwards method calls to a wrapped object through `__call()` using an explicit allowlist, so a decorator only has to implement the behavior it actually changes.

Installation
------------

[](#installation)

```
composer require phpnomad/decorator
```

Quick Start
-----------

[](#quick-start)

Add the trait to a class that wraps another instance, assign the wrapped object, and list the methods you want forwarded.

```
