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