@@ -39,47 +39,47 @@ |
||
| 39 | 39 | class RequestFactory implements RequestFactoryInterface |
| 40 | 40 | { |
| 41 | 41 | |
| 42 | - /** |
|
| 43 | - * {@inheritdoc} |
|
| 44 | - */ |
|
| 45 | - public function createRequest(string $method, $uri) : RequestInterface |
|
| 46 | - { |
|
| 47 | - return new Request($method, $uri); |
|
| 48 | - } |
|
| 42 | + /** |
|
| 43 | + * {@inheritdoc} |
|
| 44 | + */ |
|
| 45 | + public function createRequest(string $method, $uri) : RequestInterface |
|
| 46 | + { |
|
| 47 | + return new Request($method, $uri); |
|
| 48 | + } |
|
| 49 | 49 | |
| 50 | - /** |
|
| 51 | - * Creates JSON request |
|
| 52 | - * |
|
| 53 | - * @param string $method |
|
| 54 | - * @param string|UriInterface|null $uri |
|
| 55 | - * @param mixed $data |
|
| 56 | - * @param int $options |
|
| 57 | - * @param int $depth |
|
| 58 | - * |
|
| 59 | - * @return RequestInterface |
|
| 60 | - * |
|
| 61 | - * @throws InvalidArgumentException |
|
| 62 | - * If the data cannot be encoded. |
|
| 63 | - */ |
|
| 64 | - public function createJsonRequest( |
|
| 65 | - string $method, |
|
| 66 | - $uri, |
|
| 67 | - $data, |
|
| 68 | - int $options = 0, |
|
| 69 | - int $depth = 512 |
|
| 70 | - ) : RequestInterface { |
|
| 71 | - json_encode(''); // reset previous error... |
|
| 72 | - $content = json_encode($data, $options, $depth); |
|
| 73 | - if (JSON_ERROR_NONE <> json_last_error()) { |
|
| 74 | - throw new InvalidArgumentException(json_last_error_msg()); |
|
| 75 | - } |
|
| 50 | + /** |
|
| 51 | + * Creates JSON request |
|
| 52 | + * |
|
| 53 | + * @param string $method |
|
| 54 | + * @param string|UriInterface|null $uri |
|
| 55 | + * @param mixed $data |
|
| 56 | + * @param int $options |
|
| 57 | + * @param int $depth |
|
| 58 | + * |
|
| 59 | + * @return RequestInterface |
|
| 60 | + * |
|
| 61 | + * @throws InvalidArgumentException |
|
| 62 | + * If the data cannot be encoded. |
|
| 63 | + */ |
|
| 64 | + public function createJsonRequest( |
|
| 65 | + string $method, |
|
| 66 | + $uri, |
|
| 67 | + $data, |
|
| 68 | + int $options = 0, |
|
| 69 | + int $depth = 512 |
|
| 70 | + ) : RequestInterface { |
|
| 71 | + json_encode(''); // reset previous error... |
|
| 72 | + $content = json_encode($data, $options, $depth); |
|
| 73 | + if (JSON_ERROR_NONE <> json_last_error()) { |
|
| 74 | + throw new InvalidArgumentException(json_last_error_msg()); |
|
| 75 | + } |
|
| 76 | 76 | |
| 77 | - $request = new Request($method, $uri, [ |
|
| 78 | - 'Content-Type' => 'application/json; charset=UTF-8', |
|
| 79 | - ]); |
|
| 77 | + $request = new Request($method, $uri, [ |
|
| 78 | + 'Content-Type' => 'application/json; charset=UTF-8', |
|
| 79 | + ]); |
|
| 80 | 80 | |
| 81 | - $request->getBody()->write($content); |
|
| 81 | + $request->getBody()->write($content); |
|
| 82 | 82 | |
| 83 | - return $request; |
|
| 84 | - } |
|
| 83 | + return $request; |
|
| 84 | + } |
|
| 85 | 85 | } |