Skip to content

Commit

Permalink
drop polyfill code for php < 5.6
Browse files Browse the repository at this point in the history
  • Loading branch information
gossi committed Jul 1, 2017
1 parent 47635a5 commit 45a4cfe
Showing 1 changed file with 1 addition and 22 deletions.
23 changes: 1 addition & 22 deletions src/JsonException.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,7 @@
class JsonException extends \Exception {

public function __construct($message = '', $code = 0, \Exception $previous = null) {
$message = 'Unknown Error';

if (function_exists('json_last_error_msg')) {
$message = json_last_error_msg();
} else {
$messages = [
Json::ERROR_NONE => 'No error has occurred',
Json::ERROR_DEPTH => 'Maximum stack depth exceeded',
Json::ERROR_STATE_MISMATCH => 'State mismatch (invalid or malformed JSON)',
Json::ERROR_CTRL_CHAR => 'Control character error, possibly incorrectly encoded',
Json::ERROR_SYNTAX => 'Syntax error',
Json::ERROR_UTF8 => 'Malformed UTF-8 characters, possibly incorrectly encoded',
Json::ERROR_RECURSION => 'Recursion detected',
Json::ERROR_INF_OR_NAN => 'Inf and NaN cannot be JSON encoded',
Json::ERROR_UNSUPPORTED_TYPE => 'Type is not supported'
];

if (isset($messages[$code])) {
$message = $messages[$code];
}
}

$message = json_last_error_msg();
parent::__construct($message, $code, $previous);
}
}

0 comments on commit 45a4cfe

Please sign in to comment.