@@ -39,114 +39,74 @@ public function __construct(
3939 $ this ->streamFactory = $ streamFactory ?: Psr17FactoryDiscovery::findStreamFactory ();
4040 }
4141
42- /**
43- * @return string
44- */
4542 public function getBaseUri (): string
4643 {
4744 return $ this ->baseUri ;
4845 }
4946
50- /**
51- * @param string $baseUri
52- */
5347 public function setBaseUri (string $ baseUri ): void
5448 {
5549 $ this ->baseUri = $ baseUri ;
5650 }
5751
58- /**
59- * @return array
60- */
6152 public function getDefaultHeaders (): array
6253 {
6354 return $ this ->defaultHeaders ;
6455 }
6556
66- /**
67- * @param array $defaultHeaders
68- */
6957 public function setDefaultHeaders (array $ defaultHeaders ): void
7058 {
7159 $ this ->defaultHeaders = $ defaultHeaders ;
7260 }
7361
7462 /**
75- * @param string $endpoint
76- * @param array $headers
77- *
7863 * @throws \Psr\Http\Client\ClientExceptionInterface
79- *
80- * @return \Psr\Http\Message\ResponseInterface
8164 */
8265 public function get (string $ endpoint , array $ headers = []): ResponseInterface
8366 {
8467 return $ this ->request ('GET ' , $ endpoint , null , $ headers );
8568 }
8669
8770 /**
88- * @param string $endpoint
89- * @param string|resource|\Psr\Http\Message\StreamInterface|null $body
90- * @param array $headers
71+ * @param string|resource|\Psr\Http\Message\StreamInterface|null $body
9172 *
9273 * @throws \Psr\Http\Client\ClientExceptionInterface
93- *
94- * @return \Psr\Http\Message\ResponseInterface
9574 */
9675 public function post (string $ endpoint , $ body , array $ headers = []): ResponseInterface
9776 {
9877 return $ this ->request ('POST ' , $ endpoint , $ body , $ headers );
9978 }
10079
10180 /**
102- * @param string $endpoint
103- * @param string|resource|\Psr\Http\Message\StreamInterface|null $body
104- * @param array $headers
81+ * @param string|resource|\Psr\Http\Message\StreamInterface|null $body
10582 *
10683 * @throws \Psr\Http\Client\ClientExceptionInterface
107- *
108- * @return \Psr\Http\Message\ResponseInterface
10984 */
11085 public function patch (string $ endpoint , $ body , array $ headers = []): ResponseInterface
11186 {
11287 return $ this ->request ('PATCH ' , $ endpoint , $ body , $ headers );
11388 }
11489
11590 /**
116- * @param string $endpoint
117- * @param array $headers
118- *
11991 * @throws \Psr\Http\Client\ClientExceptionInterface
120- *
121- * @return \Psr\Http\Message\ResponseInterface
12292 */
12393 public function delete (string $ endpoint , array $ headers = []): ResponseInterface
12494 {
12595 return $ this ->request ('DELETE ' , $ endpoint , null , $ headers );
12696 }
12797
12898 /**
129- * @param string $method
130- * @param string $endpoint
131- * @param string|resource|\Psr\Http\Message\StreamInterface|null $body
132- * @param array $headers
99+ * @param string|resource|\Psr\Http\Message\StreamInterface|null $body
133100 *
134101 * @throws \Psr\Http\Client\ClientExceptionInterface
135- *
136- * @return \Psr\Http\Message\ResponseInterface
137102 */
138103 public function request (string $ method , string $ endpoint , $ body = null , array $ headers = []): ResponseInterface
139104 {
140105 return $ this ->client ->sendRequest ($ this ->buildRequest ($ method , $ endpoint , $ body , $ headers ));
141106 }
142107
143108 /**
144- * @param string $method
145- * @param string $endpoint
146- * @param string|resource|\Psr\Http\Message\StreamInterface|null $body
147- * @param array $headers
148- *
149- * @return \Psr\Http\Message\RequestInterface
109+ * @param string|resource|\Psr\Http\Message\StreamInterface|null $body
150110 */
151111 protected function buildRequest (string $ method , string $ endpoint , $ body = null , array $ headers = []): RequestInterface
152112 {
@@ -156,7 +116,7 @@ protected function buildRequest(string $method, string $endpoint, $body = null,
156116 if (is_resource ($ body )) {
157117 $ body = $ this ->streamFactory ->createStreamFromResource ($ body );
158118 }
159- if (!($ body instanceof StreamInterface)) {
119+ if (! ($ body instanceof StreamInterface)) {
160120 $ body = $ this ->streamFactory ->createStream ($ body );
161121 }
162122
@@ -170,11 +130,6 @@ protected function buildRequest(string $method, string $endpoint, $body = null,
170130 return $ request ;
171131 }
172132
173- /**
174- * @param string $endpoint
175- *
176- * @return string
177- */
178133 protected function getEndpoint (string $ endpoint ): string
179134 {
180135 if (strpos ($ endpoint , 'http:// ' ) === 0 || strpos ($ endpoint , 'https:// ' ) === 0 ) {
@@ -184,11 +139,6 @@ protected function getEndpoint(string $endpoint): string
184139 return $ this ->baseUri .$ endpoint ;
185140 }
186141
187- /**
188- * @param array $headers
189- *
190- * @return array
191- */
192142 protected function mergeHeaders (array $ headers ): array
193143 {
194144 return array_merge ($ this ->defaultHeaders , $ headers );
0 commit comments