Heacy rewrite/cleanup:
[mailer.git] / inc / libs / yoomedia_functions.php
index 7007190e74535479bc73ae392a462e5d7576a3bd..3c7ce1d13bfdc7f790ba8ce0b190c45eaf19b78a 100644 (file)
@@ -111,14 +111,14 @@ function YOOMEDIA_TEST_CONFIG ($data) {
        $errorCode = YOOMEDIA_GET_ERRORCODE_FROM_RESULT($response);
 
        // Log the response if failed
-       if ((count($response) == 0) && ($errorCode > 0)) {
+       if ((!isFilledArray($response)) && (isValidNumber($errorCode))) {
                // Queries depleted (as we count here!)
                logDebugMessage(__FUNCTION__, __LINE__, 'Requested depleted. Maxmimum was: ' . getConfig('yoomedia_requests_total') . ',errorCode=' . $errorCode);
                $errorCode = -1;
-       } elseif ((($errorCode <= 4) && ($errorCode > 0)) || ($errorCode >= 8)) {
+       } elseif ((($errorCode <= 4) && (isValidNumber($errorCode))) || ($errorCode >= 8)) {
                // An error has returned from the account
                logDebugMessage(__FUNCTION__, __LINE__, 'Unexpected error code ' . $errorCode . ' received.');
-       } elseif ((count($response) > 0) && ($errorCode != 0)) {
+       } elseif ((isFilledArray($response)) && (isValidNumber($errorCode))) {
                // Log serialized raw response
                logDebugMessage(__FUNCTION__, __LINE__, 'errorCode=' . $errorCode . ',response=' . base64_encode(serialize($response)));
                $errorCode = -1;
@@ -141,7 +141,7 @@ function YOOMEDIA_GET_PARSED_RESULT_TEXTMAILS () {
        $result = array();
 
        // Parse the response
-       if (count($response) > 0) {
+       if (isFilledArray($response)) {
                $result = YOOMEDIA_PARSE_RESPONSE($response, 'textmail');
        } // END - if
 
@@ -158,7 +158,7 @@ function YOOMEDIA_PARSE_RESPONSE ($response, $type) {
        $dummy = removeHttpHeaderFromResponse($response);
 
        // If there is no result, abort here
-       if (count($dummy) == 0) {
+       if (!isFilledArray($dummy)) {
                // Empty response from API
                reportBug(__FUNCTION__, __LINE__, 'Empty result from API received. response()=' . count($response) . ',type=' . $type);
                return array();
@@ -426,7 +426,7 @@ function YOOMEDIA_GET_ERRORCODE_FROM_RESULT ($response) {
                                $code = -999;
                        } // END - if
                }
-       } elseif (count($response) == 0) {
+       } elseif (!isFilledArray($response)) {
                // All fine, but empty result
                $code = '0';
        } else {