PHPackages                             n7olkachev/php-simple-delegator - 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. n7olkachev/php-simple-delegator

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

n7olkachev/php-simple-delegator
===============================

Simple decorator trait for PHP

v1.0.0(8y ago)213MITPHPPHP ^7.0

Since Aug 28Pushed 8y ago1 watchersCompare

[ Source](https://github.com/n7olkachev/php-simple-delegator)[ Packagist](https://packagist.org/packages/n7olkachev/php-simple-delegator)[ Docs](https://github.com/n7olkachev/php-simple-delegator)[ RSS](/packages/n7olkachev-php-simple-delegator/feed)WikiDiscussions master Synced today

READMEChangelog (1)Dependencies (1)Versions (2)Used By (0)

Simple Delegator
================

[](#simple-delegator)

[![](https://camo.githubusercontent.com/bf145b0037e1d79cc706e3e3d9004c734fb81733ffe45a2e4e431ddb91ed79dd/68747470733a2f2f7765627365637265742e62792f696d616765732f6c6f676f2d6769746875622e706e67)](https://websecret.by)

[![Code quality](https://camo.githubusercontent.com/4a8a27da3fd27ad3705f35f256f09face878581e905131475da8f2746b2a05fe/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f6e376f6c6b61636865762f7068702d73696d706c652d64656c656761746f722e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/n7olkachev/php-simple-delegator/)[![Licence](https://camo.githubusercontent.com/0cf78cc19c964cf71ddfa1bf6353569ad0782ec14747ebd5ceb4d9502e5f7708/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f6e376f6c6b61636865762f7068702d73696d706c652d64656c656761746f722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/n7olkachev/php-simple-delegator)[![Build Status](https://camo.githubusercontent.com/fbe94721a6733fe58fb1c297cdd4ecd9fa5a1190b2beac434bb497ff1aae34ca/68747470733a2f2f7472617669732d63692e6f72672f6e376f6c6b61636865762f7068702d73696d706c652d64656c656761746f722e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/n7olkachev/php-simple-delegator)

Why?
----

[](#why)

You can watch Jeffrey Way's video from Laracon US 2017 with usage example:  (35:00)

Examples
--------

[](#examples)

Suppose, we want to create Presenter for our User model:

```
class User extends Model
{
    protected $fillable = [
        'name',
    ];
}

class UserPresenter
{
    use SimpleDelegator;

    protected $user;

    public function __construct($user)
    {
        $this->user = $user;
    }

    protected function delegatee()
    {
        return $this->user;
    }

    public function formattedName()
    {
        return 'Decorated ' . $this->user->name;
    }
}

$decoratedUser = new UserPresenter($user);

$decoratedUser->formattedName() // call to decorator method
$decoratedUser->name // gets original name from User model
```

Or, we want to add some additional behavior to our class (as in Jeffrey's example):

```
class NotifyingThread
{
    protected $thread;

    public function __construct($thread)
    {
        $this->thread = $thread;
    }

    public function addReply()
    {
        $reply = $this->thread->addReply();

        Notification::send(
            $reply->mentionedUsers(),
            new YouWereMentioned($reply)
        );
    }
}

$thread = new NotifyingThread($thread);

$thread->addReply($data); // default logic + sending notification
```

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

[](#installation)

You can install the package via composer:

```
composer require n7olkachev/php-simple-delegator
```

Next, add SimpleDelegator trait to your Decorator class:

```
use SimpleDelegator;
```

Testing
-------

[](#testing)

```
$ composer test
```

Credits
-------

[](#credits)

- [Nikita Tolkachev](https://github.com/n7olkachev)

Sponsored by
------------

[](#sponsored-by)

Web agency based in Minsk, Belarus

License
-------

[](#license)

The MIT License (MIT)

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity58

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

3177d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/b1dde1980432378072b5f61d495c578baeaa3ac833dd16e99a2db03c642e4a9a?d=identicon)[n7olkachev](/maintainers/n7olkachev)

---

Top Contributors

[![n7olkachev](https://avatars.githubusercontent.com/u/3993345?v=4)](https://github.com/n7olkachev "n7olkachev (6 commits)")

---

Tags

decoratorsphpsimpledelegatorphpSimpledecoratorwebsecret

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/n7olkachev-php-simple-delegator/health.svg)

```
[![Health](https://phpackages.com/badges/n7olkachev-php-simple-delegator/health.svg)](https://phpackages.com/packages/n7olkachev-php-simple-delegator)
```

###  Alternatives

[fab2s/souuid

Simple Ordered Uuid Generator in PHP

13573.2k1](/packages/fab2s-souuid)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
