Created
January 27, 2015 18:55
-
-
Save vojtech-dobes/e5fb429b5f923cfabf90 to your computer and use it in GitHub Desktop.
Decorator
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 | |
trait Decorator | |
{ | |
/** @var object */ | |
private $decorated; | |
public function __construct($decorated) | |
{ | |
$this->decorated = $decorated; | |
} | |
public function __call($name, $args) | |
{ | |
$result = call_user_func_array([$this->decorated, $name], $args); | |
return ($result === $this->decorated) ? $this : $result; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment