The OIS answer is really good, although I could see that there might be confusion if the object suddenly changes to something else. That is, you expect that at the end of your chain you will get the same object. To avoid this problem, I would add a private variable to tell the class whether to really do anything. If the class was stopped, each class immediately returns $this . This gives you the added benefit of restarting execution.
class MyClass { private $halt; function __call($func, $args) { if ($this->halt) { return $this; } else { return $this->$func($args); } } private function isRequestParameter() {
This can be placed in the parent class, so you do not need to duplicate this code.
source share