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

v1.0.0 2015-08-09 13:45 UTC

This package is not auto-updated.

Last update: 2022-06-11 05:49:55 UTC


README

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'
));