Last active
July 14, 2019 11:48
-
-
Save ovr/19cbe2e8c5de17e92de896bdd61ff0e7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class RequestBuilder | |
{ | |
/** | |
* @var HttpStack | |
*/ | |
private $httpStack; | |
/** | |
* @param HttpStack $httpStack | |
*/ | |
public function __construct(HttpStack $httpStack) | |
{ | |
$this->httpStack = $httpStack; | |
} | |
public function createRequest($method, $uri, $payload): RequestInterface | |
{ | |
$request = $this->httpStack->createRequest($method, $uri); | |
if ($payload) { | |
$request = $request->withBody($this->httpStack->createStream(json_encode($payload))); | |
} | |
return $request; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment