The Volvo of calling functions: A lesson in defensive coding.

if (is_object($x) && is_object($y)){
    if (method_exists($x, "isValid") && method_exists($y, "isValid")) {
        if ($x->isValid() && $y->isValid()){
            doSomething($x, $y);
        }
    }
}
Advertisements