1 | <?php |
||
24 | class RequestBuilder |
||
25 | { |
||
26 | /** |
||
27 | * @var RequestFactoryInterface|null |
||
28 | */ |
||
29 | private $requestFactory; |
||
30 | |||
31 | /** |
||
32 | * @var StreamFactoryInterface|null |
||
33 | */ |
||
34 | private $streamFactory; |
||
35 | |||
36 | /** |
||
37 | * @var MultipartStreamBuilder |
||
38 | */ |
||
39 | private $multipartStreamBuilder; |
||
40 | |||
41 | /** |
||
42 | * Creates a new PSR-7 request. |
||
43 | * |
||
44 | * @param array|string|null $body Request body. If body is an array we will send a as multipart stream request. |
||
45 | * If array, each array *item* MUST look like: |
||
46 | * array ( |
||
47 | * 'content' => string|resource|StreamInterface, |
||
48 | 2 | * 'name' => string, |
|
49 | * 'filename'=> string (optional) |
||
50 | 2 | * 'headers' => array (optinal) ['header-name' => 'header-value'] |
|
51 | 1 | * ) |
|
52 | */ |
||
53 | public function create(string $method, string $uri, array $headers = [], $body = null): RequestInterface |
||
79 | |||
80 | private function getRequestFactory(): RequestFactoryInterface |
||
88 | |||
89 | public function setRequestFactory(RequestFactoryInterface $requestFactory): self |
||
95 | |||
96 | private function getStreamFactory(): StreamFactoryInterface |
||
104 | |||
105 | public function setStreamFactory(StreamFactoryInterface $streamFactory): self |
||
111 | |||
112 | private function getMultipartStreamBuilder(): MultipartStreamBuilder |
||
120 | |||
121 | public function setMultipartStreamBuilder(MultipartStreamBuilder $multipartStreamBuilder): self |
||
127 | |||
128 | private function createRequest(string $method, string $uri, array $headers, StreamInterface $stream) |
||
138 | } |
||
139 |