Skip to content

Commit e1cf1ae

Browse files
authored
Merge pull request #24 from limenet/master
Don't double JSON-encode the request
2 parents ca80e2c + 70ee68f commit e1cf1ae

File tree

2 files changed

+4
-8
lines changed

2 files changed

+4
-8
lines changed

src/Adapter/Guzzle.php

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -67,13 +67,11 @@ public function post(String $uri, array $headers = [], array $body = []): Respon
6767
*/
6868
public function put(String $uri, array $headers = [], array $body = []): ResponseInterface
6969
{
70-
$jsonBody = json_encode($body);
71-
7270
$response = $this->client->put(
7371
$uri,
7472
[
7573
'headers' => $headers,
76-
'json' => $jsonBody
74+
'json' => $body
7775
]
7876
);
7977

@@ -86,13 +84,11 @@ public function put(String $uri, array $headers = [], array $body = []): Respons
8684
*/
8785
public function patch(String $uri, array $headers = [], array $body = []): ResponseInterface
8886
{
89-
$jsonBody = json_encode($body);
90-
9187
$response = $this->client->patch(
9288
$uri,
9389
[
9490
'headers' => $headers,
95-
'json' => $jsonBody
91+
'json' => $body
9692
]
9793
);
9894

tests/Adapter/GuzzleTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public function testPut()
5858
$this->assertEquals("application/json", $headers["Content-Type"][0]);
5959

6060
$body = json_decode($response->getBody());
61-
$this->assertEquals("Testing a PUT request.", json_decode($body->json)->{"X-Put-Test"});
61+
$this->assertEquals("Testing a PUT request.", $body->json->{"X-Put-Test"});
6262
}
6363

6464
public function testPatch()
@@ -73,7 +73,7 @@ public function testPatch()
7373
$this->assertEquals("application/json", $headers["Content-Type"][0]);
7474

7575
$body = json_decode($response->getBody());
76-
$this->assertEquals("Testing a PATCH request.", json_decode($body->json)->{"X-Patch-Test"});
76+
$this->assertEquals("Testing a PATCH request.", $body->json->{"X-Patch-Test"});
7777
}
7878

7979
public function testDelete()

0 commit comments

Comments
 (0)