Created
March 5, 2014 02:52
-
-
Save anthonybishopric/9360270 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
interface Eater | |
{ | |
public function eat(Food $food); | |
} | |
class Robot | |
{ | |
public function getDiagram() { | |
return "010010110110100101"; | |
} | |
} | |
$builder = new \Shmock\ClassBuilder\ClassBuilder(); | |
$builder->setName("RobotDog"); // optional - CB will find a unique name for you | |
$builder->setExtends("Robot"); | |
$builder->addImplements("Eater"); | |
$builder->addMethod("eat", function(Food $food) { | |
return "YUM YUM ROBOT DOG BARKS AND EATS"; | |
}, ["Food \$food"]); | |
$robotDogClass = $builder->create(); | |
$robotDog = new RobotDog(); // class now exists | |
// we could alternatively say new $robotDogClass | |
$robotDog->eat(new Bacon()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment