PHPackages                             dgame/php-object - 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. dgame/php-object

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

dgame/php-object
================

php object

v0.8.0(7y ago)033.3k↓50%12MITPHPPHP ^7.1

Since Apr 8Pushed 6y ago1 watchersCompare

[ Source](https://github.com/Dgame/php-object)[ Packagist](https://packagist.org/packages/dgame/php-object)[ Docs](https://github.com/php-object)[ RSS](/packages/dgame-php-object/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (4)Versions (15)Used By (2)

php-object
==========

[](#php-object)

[![Scrutinizer Code Quality](https://camo.githubusercontent.com/15189bd649d5228dca88de68a15f34f908f708a48c4649a90eb9581988fe1a96/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f4467616d652f7068702d6f626a6563742f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/Dgame/php-object/?branch=master)[![codecov](https://camo.githubusercontent.com/3f1b726c1c65775ee23e4f3ec3d6c0ba284fb1378ff00792f244c6a3a02279b4/68747470733a2f2f636f6465636f762e696f2f67682f4467616d652f7068702d6f626a6563742f6272616e63682f6d61737465722f67726170682f62616467652e737667)](https://codecov.io/gh/Dgame/php-object)[![Build Status](https://camo.githubusercontent.com/b411871fcf2e2937a516326acb91692120c8fb4926b0549d7bd7301c2e0a1732/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f4467616d652f7068702d6f626a6563742f6261646765732f6275696c642e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/Dgame/php-object/build-status/master)[![StyleCI](https://camo.githubusercontent.com/789595b43bfc7bc9e2fe05fb980f8124b351e7e2f21b4444ff47cb2f7df3ec0d/68747470733a2f2f7374796c6563692e696f2f7265706f732f38373437353830352f736869656c643f6272616e63683d6d6173746572)](https://styleci.io/repos/87475805)[![Build Status](https://camo.githubusercontent.com/3569688c0875a45519f262b0c1089c21c6d7fe5d5e817b92629a918b12da8382/68747470733a2f2f7472617669732d63692e6f72672f4467616d652f7068702d6f626a6563742e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/Dgame/php-object)

---

An intelligent facade around your object to protect it from any harm.
---------------------------------------------------------------------

[](#an-intelligent-facade-around-your-object-to-protect-it-from-any-harm)

### hasMethod

[](#hasmethod)

```
$facade = new ObjectFacade(new Exception());
$this->assertTrue($facade->hasMethod('getMessage'));
$this->assertFalse($facade->hasMethod('foo'));
```

### hasProperty

[](#hasproperty)

```
$facade = new ObjectFacade(new Exception());
foreach (['message', 'code', 'file', 'line'] as $property) {
    $this->assertTrue($facade->hasProperty($property));
}
$this->assertFalse($facade->hasProperty('foo'));
```

### getPropertyByName

[](#getpropertybyname)

```
$facade = new ObjectFacade(new Exception());
foreach (['message', 'code', 'file', 'line'] as $name) {
    $property = $facade->getPropertyByName($name);

    $this->assertNotNull($property);
    $this->assertEquals($name, $property->getName());
    $this->assertNotEquals(0, ReflectionProperty::IS_PROTECTED & $property->getModifiers());
}
```

### getMethodByName

[](#getmethodbyname)

```
$facade = new ObjectFacade(new Exception());
$method = $facade->getMethodByName('getMessage');

$this->assertNotNull($method);
$this->assertEquals('getMessage', $method->getName());
$this->assertNotEquals(0, (ReflectionMethod::IS_PUBLIC | ReflectionMethod::IS_FINAL) & $method->getModifiers());
```

### getGetterMethod

[](#getgettermethod)

```
$facade = new ObjectFacade(new Exception());
$method = $facade->getGetterMethod('message');

$this->assertNotNull($method);
$this->assertEquals('getMessage', $method->getName());
```

### getSetterMethod

[](#getsettermethod)

```
$facade = new ObjectFacade(
    new class() {
        public function setFoo()
        {
        }
    }
);

$method = $facade->getSetterMethod('foo');

$this->assertNotNull($method);
$this->assertEquals('setFoo', $method->getName());
```

### getValueByMethod

[](#getvaluebymethod)

```
$exception = new Exception('Test');
$facade    = new ObjectFacade($exception);

$this->assertEquals($exception, $facade->getObject());
$this->assertEquals('Test', $facade->getValueByMethod('message'));
$this->assertEquals($exception->getMessage(), $facade->getValueByMethod('message'));
$this->assertEquals($exception->getFile(), $facade->getValueByMethod('file'));
$this->assertEquals($exception->getLine(), $facade->getValueByMethod('line'));
$this->assertNull($facade->getValueByMethod('unknown'));
```

### getValueByProperty

[](#getvaluebyproperty)

```
$facade = new ObjectFacade(
    new class() {
        public $foo = 42;
        public $bar = Exception::class;
    }
);

$this->assertEquals(42, $facade->getValueByProperty('foo'));
$this->assertEquals(Exception::class, $facade->getValueByProperty('bar'));
$this->assertNull($facade->getValueByProperty('unknown'));

$facade = new ObjectFacade(new Exception());

$this->assertNull($facade->getValueByProperty('line')); // not a public property
$this->assertNull($facade->getValueByProperty('file')); // not a public property
```

### setValueByMethod

[](#setvaluebymethod)

```
$facade = new ObjectFacade(
  new class() {
      private $foo = 42;
      private $bar;

      public function setFoo(int $foo)
      {
          $this->foo = $foo;
      }

      public function setFooBar()
      {
          $this->foo = 1;
          $this->bar = 2;
      }

      public function getFoo(): int
      {
          return $this->foo;
      }

      public function setBar(int $bar = null)
      {
          $this->bar = $bar;
      }

      public function getBar()
      {
          return $this->bar;
      }
  }
);

$this->assertEquals(42, $facade->getValueByMethod('foo'));
$facade->setValueByMethod('foo', 23);
$this->assertEquals(23, $facade->getValueByMethod('foo'));
$facade->setValueByMethod('foo', null); // "setFoo" does not accept null => keep the old value
$this->assertEquals(23, $facade->getValueByMethod('foo'));
$facade->setValueByMethod('foo', 'abc'); // "setFoo" does not accept a string => keep the old value
$this->assertEquals(23, $facade->getValueByMethod('foo'));

$this->assertNull($facade->getValueByMethod('bar'));
$facade->setValueByMethod('bar', 1337);
$this->assertEquals(1337, $facade->getValueByMethod('bar'));
$facade->setValueByMethod('bar', null);
$this->assertNull($facade->getValueByMethod('bar'));

$facade->setValueByMethod('foobar', uniqid());
$this->assertEquals(1, $facade->getValueByMethod('foo'));
$this->assertEquals(2, $facade->getValueByMethod('bar'));
```

### setValueByProperty

[](#setvaluebyproperty)

```
$facade = new ObjectFacade(
    new class() {
        public $foo = 42;
    }
);

$this->assertEquals(42, $facade->getValueByProperty('foo'));
$this->assertEquals($facade->getObject()->foo, $facade->getValueByProperty('foo'));
$facade->setValueByProperty('foo', 23);
$this->assertEquals(23, $facade->getValueByProperty('foo'));
$this->assertEquals($facade->getObject()->foo, $facade->getValueByProperty('foo'));
$facade->setValueByProperty('foo', null);
$this->assertNull($facade->getValueByProperty('foo'));
$this->assertEquals($facade->getObject()->foo, $facade->getValueByProperty('foo'));
$facade->setValueByProperty('foo', 1337);
$this->assertEquals(1337, $facade->getValueByProperty('foo'));
$this->assertEquals($facade->getObject()->foo, $facade->getValueByProperty('foo'));
```

### setValue / getValue

[](#setvalue--getvalue)

```
$facade = new ObjectFacade(
    new class() {
        public $foo = 42;
    }
);

$facade->setValue('foo', 3537);
$this->assertEquals(3537, $facade->getValue('foo'));
```

```
new class() {
    private $foo = 42;

    public function setFoo(int $foo)
    {
        $this->foo = $foo;
    }
}

$facade->setValue('foo', 3537);
$this->assertEquals(3537, $facade->getValue('foo'));
```

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity26

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity56

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 ~43 days

Recently: every ~53 days

Total

14

Last Release

2761d ago

PHP version history (2 changes)v0.1.0PHP &gt;=7.0

v0.5.0PHP ^7.1

### Community

Maintainers

![](https://www.gravatar.com/avatar/2a9fa98c1a3e70a521430fc2fba266657b2c981b5d8a36bf236fad01f9846dcd?d=identicon)[Dgame](/maintainers/Dgame)

---

Top Contributors

[![Dgame](https://avatars.githubusercontent.com/u/2406877?v=4)](https://github.com/Dgame "Dgame (42 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/dgame-php-object/health.svg)

```
[![Health](https://phpackages.com/badges/dgame-php-object/health.svg)](https://phpackages.com/packages/dgame-php-object)
```

PHPackages © 2026

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