Skip to content

Instantly share code, notes, and snippets.

@ovr
Last active July 14, 2019 11:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ovr/19cbe2e8c5de17e92de896bdd61ff0e7 to your computer and use it in GitHub Desktop.
Save ovr/19cbe2e8c5de17e92de896bdd61ff0e7 to your computer and use it in GitHub Desktop.
<?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