PHPackages                             miladm/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. miladm/data-object

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

miladm/data-object
==================

simply control your data with data object method

1.1.1(5y ago)02161Apache-2.0PHP

Since Nov 14Pushed 5y ago1 watchersCompare

[ Source](https://github.com/MiladMohebnia/PHP_dataObject)[ Packagist](https://packagist.org/packages/miladm/data-object)[ RSS](/packages/miladm-data-object/feed)WikiDiscussions master Synced 1w ago

READMEChangelogDependenciesVersions (4)Used By (1)

create data object
==================

[](#create-data-object)

1. just extend this class and set attributes and methods you need.

    ```
    use miladm\DataObject;

    class User extends DataObject
    {
        public string $name;
        public int $age;
        public string $email;

        public function validateEmail()
        {
            return $this->email == 'miladmohebnia@gmail.com';
        }

        public function validateName()
        {
            return strlen($this->name) >= 4;
        }

        public function validate()
        {
            return $this->validateName() &&
                $this->validateEmail();
        }
    }
    ```
2. create init method for setting actions happen before object constructs.

    ```
    class User extends DataObject
    {
        public object $profile;
        public object $feed;

        public function init()
        {
            $this->profile = new Profile();
            $this->feed = Feed::class;
        }
    }
    ```
3. you can add data both with `constructor` and `injectMethod`

    1. using constructor

        ```
            class User extends DataObject
            { .... }

            $user = UserModel::get_by_id(12);
            $u = new User($user);
        ```
    2. using `injectMethod`

        ```
             class User extends DataObject
            { .... }

            $u = new User();
            $user = UserModel::get_by_id(12);
            $u->injectData($user);
        ```

Using Model inside DataObject
=============================

[](#using-model-inside-dataobject)

```
class User extends DataObject
{
    private $model;

    public function init()
    {
        $this->model = UserModel::class;
    }

    public function loadUser_byId(int $id)
    {
        $this->injectData($this->model::where(['id' => $id])->getOne());
    }
}

$user = new User;
$user->loadUser_byId(12);

// code above used as alternative to code below

// $user = UserModel::get_by_id(12);
// $u = new User($user);
```

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community9

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

Total

3

Last Release

2008d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/22d33b0e34bc66cae7ab5a979b15f2975bb87dd73d1cfa2255dae95302799d75?d=identicon)[MiladM](/maintainers/MiladM)

---

Top Contributors

[![MiladMohebnia](https://avatars.githubusercontent.com/u/6062074?v=4)](https://github.com/MiladMohebnia "MiladMohebnia (7 commits)")

### Embed Badge

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

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

###  Alternatives

[danielstjules/stringy

A string manipulation library with multibyte support

2.4k26.0M191](/packages/danielstjules-stringy)[php-stubs/woocommerce-stubs

WooCommerce function and class declaration stubs for static analysis.

942.9M66](/packages/php-stubs-woocommerce-stubs)[kisma/kisma

PHP Utility Belt

178.5k8](/packages/kisma-kisma)

PHPackages © 2026

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