PHPackages                             b2r/property-method-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. b2r/property-method-delegator

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

b2r/property-method-delegator
=============================

v0.2.1(9y ago)049MITPHPPHP &gt;=7.0

Since Feb 24Pushed 9y ago1 watchersCompare

[ Source](https://github.com/b2r/php-property-method-delegator)[ Packagist](https://packagist.org/packages/b2r/property-method-delegator)[ Docs](https://github.com/b2r/php-property-method-delegator)[ RSS](/packages/b2r-property-method-delegator/feed)WikiDiscussions master Synced 2mo ago

READMEChangelogDependencies (1)Versions (4)Used By (0)

b2rPHP: PropertyMethodDelegator
===============================

[](#b2rphp-propertymethoddelegator)

[![Build Status](https://camo.githubusercontent.com/9589643afc4ec292b45e438ff7ebbcdfc73d006c578c0d2feb11ddcfd8412549/68747470733a2f2f7472617669732d63692e6f72672f6232722f7068702d70726f70657274792d6d6574686f642d64656c656761746f722e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/b2r/php-property-method-delegator)

Delegate method to property instance

- [CHANGELOG](CHANGELOG.md)
- [Packagist](https://packagist.org/packages/b2r/property-method-delegator)

Features
--------

[](#features)

- Delegate methods to target property
- Resolve method automatically
- Define method alias

$propertyMethodDelegator structure
----------------------------------

[](#propertymethoddelegator-structure)

- Key: `strign` Property name
- Value: `array` Method definitions
    - Key: `string` Method name in **LOWER** case
    - Value: `string|bool` Delegate target method name or bool
        - `true`: Use same name
        - `false`: DO NOT resolve method if target has public metdhod

Usage
-----

[](#usage)

### Simple

[](#simple)

```
use b2r\Component\PropertyMethodDelegator\PropertyMethodDelegator;

class ArrayObjectWrapper
{
    use PropertyMethodDelegator;

    protected static $propertyMethodDelegator = [
        'arrayObject' => [],
    ];

    private $arrayObject;

    public function __construct()
    {
        $this->arrayObject = new ArrayObject();
    }
}

$a = new ArrayObjectWrapper();
$a->append(1);
var_dump($a->getArrayCopy()); #=>[1]

```

### Mixed

[](#mixed)

```
use b2r\Component\PropertyMethodDelegator\PropertyMethodDelegator;

class Foo
{
    public function doFoo()
    {
        return __METHOD__;
    }

    public function execute()
    {
        return __METHOD__;
    }

    public function run()
    {
        return __METHOD__;
    }

    public function hello() {
        return __METHOD__;
    }

    public function publicHidden()
    {
        return __METHOD__;
    }

    protected function protectedMethod()
    {
        return __METHOD__;
    }
}

class Bar
{
    public function doBar()
    {
        return __METHOD__;
    }

    public function execute()
    {
        return __METHOD__;
    }

    public function run()
    {
        return __METHOD__;
    }

    public function hello() {
        return __METHOD__;
    }

    public function publicHidden()
    {
        return __METHOD__;
    }

    protected function protectedMethod()
    {
        return __METHOD__;
    }
}

class FooBar
{
    use PropertyMethodDelegator;

    protected static $propertyMethodDelegator = [
        'foo' => [
            'execute' => true, // FooBar::execute invoke FooBar::$foo::execute
            'foo' => 'doFoo',  // FooBar::foo invoke FooBar::$foo::doFoo
            'publichidden' => false, // DO NOT invoke FooBar::$foo::publicHidden
        ],
        'bar' => [
            'run' => true, // FooBar::run invoke FooBar::$bar::run
            'bar' => 'doBar', // FooBar::bar invoke FooBar::$bar::doBar
            'publichidden' => false,  // DO NOT invoke FooBar::$bar::publicHidden
        ],
    ];

    protected $foo;
    protected $bar;

    public function __construct()
    {
        $this->foo = new Foo();
        $this->bar = new Bar();
    }
}

$foobar = new FooBar();

echo $foobar->execute(),"\n"; #=>'Foo::execute'
echo $foobar->run(),"\n"; #=>'Bar::run'
echo $foobar->foo(),"\n"; #=>'Foo::doFoo'
echo $foobar->bar(),"\n"; #=>'Bar::doBar'
echo $foobar->doFoo(),"\n"; #=>'Foo::doFoo' Automatically resolved
echo $foobar->doBar(),"\n"; #=>'Bar::doBar' Automatically resolved
echo $foobar->hello(),"\n"; #=>'Foo::hello' Automatically resolved(foo is first)

// `protectedMethod` is protected, cannot resolve delegate method
var_dump($foobar->resolveDelegateMethod('protectedMethod')); #=> false

// `publicHidden` is hidden both foo and bar, cannot resolve delegate method
var_dump($foobar->resolveDelegateMethod('publicHidden')); #=> false

#------------------------------------------------------------

/**
 * Change delegate method resolving order: bar, foo
 */
class BarFoo extends FooBar
{
    protected static $propertyMethodDelegator = [
        'bar' => [],
        'foo' => [],
    ];
}

$barfoo = new BarFoo();
echo $barfoo->hello(),"\n"; #=>'Bar::hello' Automatically resolved(bar is first)
```

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity50

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

Every ~13 days

Total

3

Last Release

3336d ago

### Community

Maintainers

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

---

Top Contributors

[![b2r](https://avatars.githubusercontent.com/u/74344?v=4)](https://github.com/b2r "b2r (12 commits)")

### Embed Badge

![Health badge](/badges/b2r-property-method-delegator/health.svg)

```
[![Health](https://phpackages.com/badges/b2r-property-method-delegator/health.svg)](https://phpackages.com/packages/b2r-property-method-delegator)
```

###  Alternatives

[zenepay/filament-buddhist-date-picker

Laravel Filament DatePicker with Bhuddist Era plugin

214.8k](/packages/zenepay-filament-buddhist-date-picker)[workerman/stomp

1010.3k6](/packages/workerman-stomp)

PHPackages © 2026

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