Skip to content

Instantly share code, notes, and snippets.

@anthonybishopric
Created March 5, 2014 02:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anthonybishopric/9360270 to your computer and use it in GitHub Desktop.
Save anthonybishopric/9360270 to your computer and use it in GitHub Desktop.
<?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