@@ -20,10 +20,10 @@ abstract class RemoteClient extends RegisterEvents
2020 public function __construct (string $ src )
2121 {
2222 if (
23- !str_starts_with ($ src , 'http:// ' ) &&
24- !str_starts_with ($ src , 'https:// ' ) &&
25- !str_starts_with ($ src , 'ws:// ' ) &&
26- !str_starts_with ($ src , 'wss:// ' )
23+ ! str_starts_with ($ src , 'http:// ' ) &&
24+ ! str_starts_with ($ src , 'https:// ' ) &&
25+ ! str_starts_with ($ src , 'ws:// ' ) &&
26+ ! str_starts_with ($ src , 'wss:// ' )
2727 ) {
2828 throw new InvalidArgumentException ('The src must not contain the protocol ' );
2929 }
@@ -44,12 +44,14 @@ public function __construct(string $src)
4444 protected function http (string $ method , string $ uri , array $ params = [], array $ opt = [], ?string $ dto = null )
4545 {
4646 $ response = $ this ->httpRaw ($ method , $ uri , $ params , $ opt );
47+
4748 return $ this ->decodeResponse ($ response , $ dto );
4849 }
4950
5051 protected function httpRaw (string $ method , string $ uri , array $ params = [], array $ opt = [])
5152 {
5253 $ keyContent = $ method === 'get ' ? 'query ' : 'json ' ;
54+
5355 return $ this ->httpClient ->request ($ method , $ uri , array_merge ([
5456 $ keyContent => $ params ,
5557 ], $ opt ));
@@ -60,7 +62,7 @@ protected function ws(string $uri, array $options = []): EnhancedClient
6062 return new EnhancedClient (str_replace ('http ' , 'ws ' , $ this ->src ).$ uri , $ options );
6163 }
6264
63- protected function decodeResponse (ResponseInterface |string $ response , string $ mapTo = null ): mixed
65+ protected function decodeResponse (ResponseInterface |string $ response , ? string $ mapTo = null ): mixed
6466 {
6567 $ body = $ response instanceof ResponseInterface ? $ response ->getBody ()->getContents () : $ response ;
6668
0 commit comments