From 4ef53806f485c47e14b3c4b00aa01c99efc8e117 Mon Sep 17 00:00:00 2001 From: Stig Bakken Date: Mon, 10 Feb 2003 14:26:19 +0000 Subject: [PATCH] * 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. --- pear/PEAR.php | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) 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; } // }}} -- 2.50.1