Skip to content

Commit

Permalink
formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
taylorotwell committed Mar 9, 2018
1 parent 1ea591d commit 39131ae
Showing 1 changed file with 6 additions and 14 deletions.
20 changes: 6 additions & 14 deletions JsonResponse.php
Expand Up @@ -86,24 +86,16 @@ public function setData($data = [])
*/
protected function hasValidJson($jsonError)
{
// No error is obviously fine
if ($jsonError === JSON_ERROR_NONE) {
return true;
}

// If the JSON_PARTIAL_OUTPUT_ON_ERROR option is set, some additional errors are fine
// (see https://secure.php.net/manual/en/json.constants.php)
if ($this->hasEncodingOption(JSON_PARTIAL_OUTPUT_ON_ERROR)) {
$acceptableErrors = [
JSON_ERROR_RECURSION,
JSON_ERROR_INF_OR_NAN,
JSON_ERROR_UNSUPPORTED_TYPE,
];

return \in_array($jsonError, $acceptableErrors);
}

return false;
return $this->hasEncodingOption(JSON_PARTIAL_OUTPUT_ON_ERROR) &&
in_array($jsonError, [
JSON_ERROR_RECURSION,
JSON_ERROR_INF_OR_NAN,
JSON_ERROR_UNSUPPORTED_TYPE,
]);
}

/**
Expand Down

0 comments on commit 39131ae

Please sign in to comment.