From f71b2aa9c17b72536e28217cb93422c851cf1ba9 Mon Sep 17 00:00:00 2001 From: Stephan Eizinga Date: Fri, 10 Jan 2020 12:25:41 +0100 Subject: [PATCH] * Removed duplicated isValidJson check --- src/SignhostClient.php | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/src/SignhostClient.php b/src/SignhostClient.php index b98496b..75b0733 100644 --- a/src/SignhostClient.php +++ b/src/SignhostClient.php @@ -85,13 +85,13 @@ public function performRequest(string $endpoint, string $method, $data = null, $ } // When data is set, we must add Content-Type: application/json header - if (isset($data) && !empty($data) && $this->isValidJson($data)) { + if (isset($data) && !empty($data)) { $headers[] = 'Content-Type: application/json'; $headers[] = 'Content-Length: ' . strlen($data); } - // for start transaction, SignHost will require the content-lenth: 0 header. - if (false !== strpos($endpoint, 'start')) { + // for start transaction, SignHost will require the content-length: 0 header. + if (($method == 'PUT' || $method == 'POST') && empty($data) && empty($filePath)) { $headers[] = 'Content-Length: 0'; } @@ -113,11 +113,6 @@ public function performRequest(string $endpoint, string $method, $data = null, $ } } - private function isValidJson($jsonString) { - json_decode($jsonString); - return (json_last_error() == JSON_ERROR_NONE); - } - /** * @throws SignhostException */