From: Stig Bakken Date: Mon, 10 Feb 2003 14:26:19 +0000 (+0000) Subject: * PEAR::isError accepts second parameter that will be matched against X-Git-Tag: RELEASE_0_5~1147 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=4ef53806f485c47e14b3c4b00aa01c99efc8e117;p=php * PEAR::isError accepts second parameter that will be matched against the error code. PEAR::isError($obj, FOO) will return true if $obj is an error object, and $obj->getCode() returns FOO. --- diff --git a/pear/PEAR.php b/pear/PEAR.php index 4663ed1a8d..48569f9dab 100644 --- a/pear/PEAR.php +++ b/pear/PEAR.php @@ -226,10 +226,13 @@ class PEAR * @access public * @return bool true if parameter is an error */ - function isError($data) { - return (bool)(is_object($data) && - (get_class($data) == 'pear_error' || - is_subclass_of($data, 'pear_error'))); + function isError($data, $code = null) + { + if (is_object($data) && (get_class($data) == 'pear_error' || + is_subclass_of($data, 'pear_error'))) { + return $code === null ? true : $data->getCode() == $code; + } + return false; } // }}}