Created
November 11, 2016 22:05
-
-
Save gong023/53624831ffa1bf44fbee66cfa7834c81 to your computer and use it in GitHub Desktop.
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
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