PHPackages                             flancer32/php\_data\_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. flancer32/php\_data\_object

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

flancer32/php\_data\_object
===========================

Simplified Data Container (inspired by Varien\_Object).

0.2.2(8y ago)16.2k↓83.3%[1 issues](https://github.com/flancer32/php_data_object/issues)1MITPHP

Since Feb 15Pushed 6y ago1 watchersCompare

[ Source](https://github.com/flancer32/php_data_object)[ Packagist](https://packagist.org/packages/flancer32/php_data_object)[ Docs](https://github.com/flancer32/php_data_object)[ RSS](/packages/flancer32-php-data-object/feed)WikiDiscussions master Synced 4w ago

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

php\_data\_object
=================

[](#php_data_object)

[![Build Status](https://camo.githubusercontent.com/8865c2600e5e052ab712b921ca6ac681c9c1ce72a1f5141955cf08ff8f0eceee/68747470733a2f2f7472617669732d63692e6f72672f666c616e63657233322f7068705f646174615f6f626a6563742e737667)](https://travis-ci.org/flancer32/php_data_object)[![codecov.io](https://camo.githubusercontent.com/79b59eee8ebf41bfed4b5f9e22c8c28fa7597627e4e4615d364ce66f3c99cc92/68747470733a2f2f636f6465636f762e696f2f6769746875622f666c616e63657233322f7068705f646174615f6f626a6563742f636f7665726167652e7376673f6272616e63683d6d6173746572)](https://codecov.io/github/flancer32/php_data_object?branch=master)

*"Smart data structures and dumb code works a lot better than the other way around."* (c) Eric S. Raymond

*"Bad programmers worry about the code. Good programmers worry about data structures and their relationships."* (c) Linus Torvalds

Overview
--------

[](#overview)

This is yet another PHP implementation of the data container (like [DTO](https://en.wikipedia.org/wiki/Data_transfer_object) / [SDO](http://php.net/manual/en/book.sdo.php)). Some kind of the wrapper around associative array. The main goal of this implementation is to be an accessor for the raw data.

Native PHP objects
------------------

[](#native-php-objects)

### Structure

[](#structure)

We can use any property of any PHP object:

```
$obj1 = new class {};
$obj2 = new class {};
$obj1->name = 'first';
$obj2->code = 'OBJ2';
$obj1->sub = $obj2;
$this->assertEquals('first', $obj1->name);
$this->assertEquals('OBJ2', $obj1->sub->code);

```

[More...](./docs/010_PhpObjects.md)

### Paths

[](#paths)

We can set/get value of the inner property in PHP style:

```
$obj->sub->code = $code;
$code = $obj->sub->code;

```

but we will have "*Undefined property*" error if `$obj->sub` property does not exist.

### Type checking

[](#type-checking)

We need to use accessors to control properties types.

This is `Customer` class with `string` property:

```
/**
 * @property string $name Customer name.
 */
class Customer
{
    public function getName() : string
    {
        return $this->name;
    }

    public function setName(string $data)
    {
        $this->name = $data;
    }
}

```

This is `Order` class with `Customer` property:

```
/**
 * @property Customer $customer
 */
class Order
{
    public function getCustomer() : Customer
    {
        return $this->customer;
    }

    public function setCustomer(Customer $data)
    {
        $this->customer = $data;
    }
}

```

This is code without errors (all types are expected):

```
$customer = new Customer();
$customer->setName('John Dow');
$order = new Order();
$order->setCustomer($customer);
$this->assertTrue(is_string($order->getCustomer()->getName()));

```

This code will throw a `\TypeError` exception:

```
$customer = new class {};
$customer->name = 'John Dow';
$order = new Order();
$order->setCustomer($customer);

```

[More...](./docs/020_TypeChecking.md)

Data Objects
------------

[](#data-objects)

### Structure

[](#structure-1)

### Paths

[](#paths-1)

With paths we will have property value if chain of properties exists or `null` otherwise:

```
$code = $obj->get('sub/code');
$code = $obj->get('/sub/code');    // equals to 'sub/code'
$code = $obj->get('/subs/0/code'); // 'subs' is array
$code = $obj->get('/sub/code/does/not/exist'); // 'null' is returned, no error is occured

```

Also we can set data property by path:

```
$obj->set('order/customer/name', 'John Dow');

```

### Type hinting

[](#type-hinting)

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

[](#installation)

Add to `composer.json`:

```
"require": {
    "flancer32/php_data_object": "0.1.0"
}

```

Development
-----------

[](#development)

```
$ composer install
$ ./vendor/bin/phpunit -c ./test/unit/phpunit.dist.xml

```

###  Health Score

24

—

LowBetter than 31% of packages

Maintenance0

Infrequent updates — may be unmaintained

Popularity19

Limited adoption so far

Community9

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

Every ~117 days

Recently: every ~161 days

Total

7

Last Release

3083d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/6083415?v=4)[F. Lancer, SIA](/maintainers/flancer32)[@flancer32](https://github.com/flancer32)

---

Top Contributors

[![flancer64](https://avatars.githubusercontent.com/u/5052385?v=4)](https://github.com/flancer64 "flancer64 (75 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

PHPackages © 2026

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