From cf6ca5a7e53f22cf18aca93126c5c2ef658d7b0a Mon Sep 17 00:00:00 2001 From: Roel van Duijnhoven Date: Fri, 29 Jan 2021 10:29:50 +0100 Subject: [PATCH] Only print as string, if not an array. --- src/OP/Reply.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/OP/Reply.php b/src/OP/Reply.php index 5436d8c..ff5f0b3 100644 --- a/src/OP/Reply.php +++ b/src/OP/Reply.php @@ -27,7 +27,7 @@ protected function _parseReply ($str = '') $arr = OP_API::convertXmlToPhpObj($dom->documentElement); - if (!is_array($arr) || !array_key_exists('reply', $arr)) { + if (!is_array($arr)) { throw new OP_API_Exception(sprintf("Could not interpret response: %s", (string)$arr)); } @@ -35,7 +35,11 @@ protected function _parseReply ($str = '') throw new OP_API_Exception("API is temporarily unavailable due to maintenance", 4005); } - if (!array_key_exists('code', $arr['reply']) || !array_key_exists('desc', $arr['reply']) || !array_key_exists('data', $arr['reply'])) { + if (!array_key_exists('reply', $arr) + || !array_key_exists('code', $arr['reply']) + || !array_key_exists('desc', $arr['reply']) + || !array_key_exists('data', $arr['reply']) + ) { throw new OP_API_Exception(sprintf("Could not interpret response, missing mandatory fields. Response: %s", print_r($arr, true))); }