Skip to content

Instantly share code, notes, and snippets.

@vojtech-dobes
Created January 27, 2015 18:55
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 vojtech-dobes/e5fb429b5f923cfabf90 to your computer and use it in GitHub Desktop.
Save vojtech-dobes/e5fb429b5f923cfabf90 to your computer and use it in GitHub Desktop.
Decorator
<?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