summaryrefslogtreecommitdiffstats
path: root/src/PurpleCode/PCurl/PJsonCurl.php
diff options
context:
space:
mode:
Diffstat (limited to 'src/PurpleCode/PCurl/PJsonCurl.php')
-rw-r--r--src/PurpleCode/PCurl/PJsonCurl.php20
1 files changed, 4 insertions, 16 deletions
diff --git a/src/PurpleCode/PCurl/PJsonCurl.php b/src/PurpleCode/PCurl/PJsonCurl.php
index 30776a0..aad8bd4 100644
--- a/src/PurpleCode/PCurl/PJsonCurl.php
+++ b/src/PurpleCode/PCurl/PJsonCurl.php
@@ -11,39 +11,27 @@
namespace PurpleCode\PCurl;
+use PurpleCode\PCurl\PCurlJsonResponse;
+
class PJsonCurl extends PCurl {
private $arrayResponse;
- private $alwaysParseResponse;
public function __construct($host) {
parent::__construct($host);
$this->arrayResponse = false;
- $this->alwaysParseResponse = true;
$this->contentTypeJson();
}
public function call($method, $url, $payload = '') {
$payload = json_encode($payload);
- return parent::call($method, $url, $payload);
- }
-
- protected function postProcessResponseBody($body, $header) {
- $body = parent::postProcessResponseBody($body, $header);
- if ($this->alwaysParseResponse || strpos($header,'application/json')!==false) {
- return json_decode($body, $this->arrayResponse);
- }
-
- return $body;
+ $response = parent::call($method, $url, $payload);
+ return new PCurlJsonResponse($response->getHeader(), $response->getBody(), $this->arrayResponse);
}
public function arrayResponse($arrayResponse = true) {
$this->arrayResponse = $arrayResponse;
}
- public function alwaysParseResponse($alwaysParseResponse = true) {
- $this->alwaysParseResponse = $alwaysParseResponse;
- }
-
}