keyvanakbary / mimic
Dead simple functional library for object prototyping, data hydration and data exposition
Installs: 31 599
Dependents: 2
Suggesters: 0
Security: 0
Stars: 21
Watchers: 3
Forks: 2
Open Issues: 0
Requires
- php: >=5.3.3
Requires (Dev)
- phpunit/phpunit: ~4.0
This package is not auto-updated.
Last update: 2024-11-09 18:22:14 UTC
README
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' ));