Skip to content

Instantly share code, notes, and snippets.

@gong023
Created November 11, 2016 22:05
Show Gist options
  • Save gong023/53624831ffa1bf44fbee66cfa7834c81 to your computer and use it in GitHub Desktop.
Save gong023/53624831ffa1bf44fbee66cfa7834c81 to your computer and use it in GitHub Desktop.
class NullObject
{
public function __call($name, $arguments)
{
return $this;
}
}
class Klass
{
public function process1()
{
try {
// do something
// throw exception if error occurs
return $this;
} catch (Exception $e) {
return new NullObject;
}
}
public function process2()
{
// do something
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment