Skip to content

Instantly share code, notes, and snippets.

@thisgeek
Created May 10, 2010 14:41
Show Gist options
  • Select an option

  • Save thisgeek/396106 to your computer and use it in GitHub Desktop.

Select an option

Save thisgeek/396106 to your computer and use it in GitHub Desktop.
class Pig {
function oink() {
print "Oink";
}
}
abstract class Decorator {
protected $obj;
function __construct($object) {
$this->obj = $object;
}
function __call($name, $args) {
return call_user_func_array(array($this->obj, $name), $args);
}
}
class FlyingPig extends Decorator {
function fly() {
print "I'm flying!";
}
}
$pig = new Pig;
$flying_pig = new FlyingPig($pig);
$flying_pig->fly();
$flying_pig->oink();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment