PHP code example of keyvanakbary / mimic
1. Go to this page and download the library: Download keyvanakbary/mimic library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
keyvanakbary / mimic example snippets
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'
));