diff options
| author | Stig Bakken <ssb@php.net> | 2003-02-10 14:26:19 +0000 |
|---|---|---|
| committer | Stig Bakken <ssb@php.net> | 2003-02-10 14:26:19 +0000 |
| commit | 4ef53806f485c47e14b3c4b00aa01c99efc8e117 (patch) | |
| tree | 4b5fd8e5b5e38438ed889045d1ff21a3def2bf12 | |
| parent | cab18bc2dede7056845c73a5aac63afd9808418a (diff) | |
| download | php-git-4ef53806f485c47e14b3c4b00aa01c99efc8e117.tar.gz | |
* 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.
| -rw-r--r-- | pear/PEAR.php | 11 |
1 files 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; } // }}} |
