Created
May 10, 2010 14:41
-
-
Save thisgeek/396106 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| 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