Skip to content

Commit e853217

Browse files
committed
* support both error codes and messages in the second parameter to
PEAR::isError()
1 parent 2063094 commit e853217

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

pear/PEAR.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,13 @@ function isError($data, $code = null)
232232
{
233233
if (is_object($data) && (get_class($data) == 'pear_error' ||
234234
is_subclass_of($data, 'pear_error'))) {
235-
return $code === null ? true : $data->getCode() == $code;
235+
if (is_null($code)) {
236+
return true;
237+
} elseif (is_string($code)) {
238+
return $data->getMessage() == $code;
239+
} else {
240+
return $data->getCode() == $code;
241+
}
236242
}
237243
return false;
238244
}

0 commit comments

Comments
 (0)