Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
This repository was archived by the owner on Aug 4, 2022. It is now read-only.

saedyousef/supreme-object

Open more actions menu

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Supreme Object

Total Downloads Latest Stable Version License wakatime


Supreme Object is to create Data Object or Data Transfer Objects for you, instead of dealing with arrays or class properties.

Installation

From the command line run:

composer require saedyousef/supreme-object

Usage

With the package now installed, you can implement the main Interface DataObject and by using the trait DataObjectTrait that have all the methods implemented for you. Here is an example of a class PostDataObject that implements the DataObject interface :

use Saedyousef\SupremeObject\Contracts\DataObject;
use Saedyousef\SupremeObject\Support\DataObjectTrait;

/**
 * @property int|null id
 * @property string title
 * @property string body 
 */
class PostDataObject implements DataObject
{
    use DataObjectTrait;
    
    public function __construct(array $properties = [])
    {
        $this->_properties = [
            'id'    => null,
            'title' => '',
            'body'  => ''
        ];

        $this->hydrate($properties);
    }
    
    /** 
    * @return int|null
    */
    public function getId()
    {
        return $this->id;
    }
}

And that's it! Now you have your data object set.


A Star on this repo would be appreciated ;)

About

PHP DataObject

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages

Morty Proxy This is a proxified and sanitized view of the page, visit original site.