Skip to content
Dead simple functional library for object prototyping, data hydration and data exposition
PHP
Branch: master
Clone or download

Latest commit

Fetching latest commit…
Cannot retrieve the latest commit at this time.

Files

Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
src
tests
.gitignore
.travis.yml
LICENSE
README.md
composer.json
phpunit.xml.dist

README.md

Mimic

Build Status

Dead simple functional library for object prototyping, data hydration and data exposition.

Installation

composer require keyvanakbary/mimic

Usage

namespace Domain;

use mimic as m;

class ComputerScientist {
    private $name;
    private $surname;
    
    public function __construct($name, $surname) {
        $this->name = $name;
        $this->surname = $surname;
    }
    
    public function rocks() {
        return $this->name . ' ' . $this->surname . ' rocks!';
    }
}

assert(m\prototype('Domain\ComputerScientist') instanceof Domain\ComputerScientist);

m\hydrate('Domain\ComputerScientist', array(
    'name' => 'John',
    'surname' => 'McCarthy'
))->rocks(); //John McCarthy rocks!

assert(m\expose(new Domain\ComputerScientist('Grace', 'Hopper')) == array(
    'name' => 'Grace',
    'surname' => 'Hopper'
));
You can’t perform that action at this time.