Skip to content

Instantly share code, notes, and snippets.

@ovr
Last active July 14, 2019 11:48
Show Gist options
  • 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