Skip to content

Commit

Permalink
* Removed duplicated isValidJson check
Browse files Browse the repository at this point in the history
  • Loading branch information
steffjenl committed Jan 10, 2020
1 parent 1dc0b6f commit f71b2aa
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions src/SignhostClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';
}

Expand All @@ -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
*/
Expand Down

0 comments on commit f71b2aa

Please sign in to comment.