1111
1212final class Client implements ClientInterface
1313{
14- /**
15- * @var string
16- */
17- private $ accessToken ;
18-
19- /**
20- * @var HttpClientInterface
21- */
22- private $ httpClient ;
23-
2414 /**
2515 * @var array
2616 */
@@ -34,29 +24,29 @@ final class Client implements ClientInterface
3424 ],
3525 ];
3626
37- public function __construct (HttpClientInterface $ httpClient )
27+ public function __construct (private HttpClientInterface $ httpClient )
3828 {
39- $ this ->httpClient = $ httpClient ;
4029 }
4130
4231 /**
4332 * @throws ClientException
4433 * @throws \RuntimeException
34+ * @throws \JsonException
4535 */
4636 public function request (string $ method , string $ path , array $ data = []): array
4737 {
4838 try {
4939 $ response = $ this ->httpClient ->request ($ method , $ path , $ data );
5040
51- return json_decode ($ response ->getBody ()->getContents (), true );
41+ return json_decode ($ response ->getBody ()->getContents (), true , 512 , JSON_THROW_ON_ERROR );
5242 } catch (GuzzleException $ e ) {
5343 throw ClientException::newException ($ e , $ method , $ path , $ data );
5444 }
5545 }
5646
5747 public static function factory (string $ accessToken , array $ httpOptions = []): self
5848 {
59- $ httpOptions = array_merge (static ::$ httpOptions , $ httpOptions );
49+ $ httpOptions = array_merge (self ::$ httpOptions , $ httpOptions );
6050 $ authorization = new Authorization ($ accessToken );
6151
6252 $ httpOptions ['handler ' ] = HandlerStack::create ();
0 commit comments