feat(json): json pecl extension may be available all the time
This commit is contained in:
5
.gitignore
vendored
5
.gitignore
vendored
@@ -1,6 +1,7 @@
|
||||
.idea
|
||||
.DS_Store
|
||||
.idea
|
||||
build
|
||||
vendor
|
||||
composer.lock
|
||||
composer.phar
|
||||
coverage
|
||||
vendor
|
||||
|
||||
@@ -8,8 +8,10 @@
|
||||
"author": "Mashape <opensource@mashape.com> (https://www.mashape.com)",
|
||||
"require": {
|
||||
"php": ">=5.4.0",
|
||||
"ext-curl": "*",
|
||||
"ext-json": "*"
|
||||
"ext-curl": "*"
|
||||
},
|
||||
"suggest": {
|
||||
"ext-json": "Allows using JSON Bodies for sending and parsing requests"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "~4.4",
|
||||
|
||||
@@ -25,12 +25,14 @@ class Response
|
||||
// make sure raw_body is the first argument
|
||||
array_unshift($json_args, $raw_body);
|
||||
|
||||
if (function_exists('json_decode')) {
|
||||
$json = call_user_func_array('json_decode', $json_args);
|
||||
|
||||
if (json_last_error() === JSON_ERROR_NONE) {
|
||||
$this->body = $json;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* if PECL_HTTP is not available use a fall back function
|
||||
|
||||
Reference in New Issue
Block a user