Skip to content

Instantly share code, notes, and snippets.

@md2perpe
Created October 2, 2015 21:54
Show Gist options
  • Save md2perpe/ce71b4509139cc1f9f1a to your computer and use it in GitHub Desktop.
Save md2perpe/ce71b4509139cc1f9f1a to your computer and use it in GitHub Desktop.
class Safe
{
protected $value;
public function __construct($value) { $this->value = $value; }
public function __call($method, $args)
{
if (is_object($this->value) && method_exists($this->value, $method)) {
return new self(call_user_func_array([$this->value, $method], $args);
}
return new self(null);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment