Skip to content
This repository was archived by the owner on Jul 29, 2020. It is now read-only.

Commit 3298885

Browse files
committed
Be Prepared for empty Json Responses
1 parent 4ffbcca commit 3298885

1 file changed

Lines changed: 12 additions & 9 deletions

File tree

src/FlexiPeeHP/FlexiBeeRO.php

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -982,7 +982,7 @@ public function rawJsonToArray($rawJson)
982982
$responseDecoded = $responseDecoded[$this->nameSpace];
983983
}
984984
} else {
985-
if($this->debug){
985+
if ($this->debug) {
986986
$this->addStatusMessage('JSON Decoder: '.$decodeError, 'error');
987987
$this->addStatusMessage($rawJson, 'debug');
988988
}
@@ -1033,14 +1033,17 @@ public function parseResponse($responseDecoded, $responseCode)
10331033

10341034
$this->lastResult = $mainResult;
10351035

1036-
if (array_key_exists('success', $mainResult) && ($mainResult['success']
1037-
== 'false')) {
1038-
$this->responseStats = ['read' => 0];
1039-
} elseif (array_key_exists('properties', $mainResult)) {
1040-
$this->responseStats = ['read' => 1];
1041-
} else {
1042-
$this->responseStats = ['read' => empty($this->rowCount) ? count($mainResult[$this->getResponseEvidence()])
1043-
: $this->rowCount];
1036+
if (!is_null($mainResult)) {
1037+
if (array_key_exists('success', $mainResult) && ($mainResult['success']
1038+
== 'false')) {
1039+
$this->responseStats = ['read' => 0];
1040+
} elseif (array_key_exists('properties', $mainResult)) {
1041+
$this->responseStats = ['read' => 1];
1042+
} else {
1043+
$this->responseStats = ['read' => empty($this->rowCount)
1044+
? count($mainResult[$this->getResponseEvidence()])
1045+
: $this->rowCount];
1046+
}
10441047
}
10451048
break;
10461049

0 commit comments

Comments
 (0)