cvs: php4 /pear PEAR.php
| From: | Stig Bakken | Date: | Mon, 10 Feb 2003 14:26:19 +0000 |
| Subject: | cvs: php4 /pear PEAR.php | ||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-8799@lists.php.net to get a copy of this message | ||
ssb Mon Feb 10 09:26:19 2003 EDT
Modified files:
/php4/pear PEAR.php
Log:
* 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.
Index: php4/pear/PEAR.php
diff -u php4/pear/PEAR.php:1.54 php4/pear/PEAR.php:1.55
--- php4/pear/PEAR.php:1.54 Sun Jan 26 18:54:19 2003
+++ php4/pear/PEAR.php Mon Feb 10 09:26:19 2003
@@ -18,7 +18,7 @@
// | Tomas V.V.Cox <cox@idecnet.com> |
// +----------------------------------------------------------------------+
//
-// $Id: PEAR.php,v 1.54 2003/01/26 23:54:19 ssb Exp $
+// $Id: PEAR.php,v 1.55 2003/02/10 14:26:19 ssb Exp $
//
define('PEAR_ERROR_RETURN', 1);
@@ -226,10 +226,13 @@
* @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;
}
// }}}