From fdd71090934ee0599fa6da405646d33a88a107f9 Mon Sep 17 00:00:00 2001 From: Marcel Hernandez Date: Wed, 3 Oct 2018 01:49:13 +0200 Subject: feedback from code review --- src/PSR7Client.php | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'src/PSR7Client.php') diff --git a/src/PSR7Client.php b/src/PSR7Client.php index b12159a5..7000018e 100644 --- a/src/PSR7Client.php +++ b/src/PSR7Client.php @@ -107,10 +107,7 @@ class PSR7Client if ($ctx['parsed']) { $request = $request->withParsedBody(json_decode($body, true)); } else if ($body !== null) { - $bodyStream = $this->streamFactory->createStream($body); - $bodyStream->write($body); - - $request = $request->withBody($bodyStream); + $request = $request->withBody($this->streamFactory->createStream($body)); } return $request; @@ -172,9 +169,11 @@ class PSR7Client continue; } - $stream = UPLOAD_ERR_OK === $f['error'] ? - $this->streamFactory->createStreamFromFile($f['tmpName']) : - $this->streamFactory->createStream(); + if (UPLOAD_ERR_OK === $f['error']) { + $stream = $this->streamFactory->createStreamFromFile($f['tmpName']); + } else { + $stream = $this->streamFactory->createStream(); + } $result[$index] = $this->uploadsFactory->createUploadedFile( $stream, -- cgit v1.2.3