@@ -30,11 +30,8 @@ public static function setApiClient(ClientInterface $client): void
3030
3131 final protected function callApi (string $ method , string $ uri , array $ options = []): ResponseInterface
3232 {
33- $ coverageId = CoverageHelper::resolveCoverageId (static ::class, $ this ->dataName ());
3433 $ uri = str_starts_with ($ uri , '/rest ' ) ? $ uri : sprintf ('%s%s ' , self ::REST_PATH_PREFIX , $ uri );
35- $ options = $ this ->optionsWithHeader ($ options , 'X-Coverage-Id ' , $ coverageId );
36-
37- return self ::getClient ()->request ($ method , $ uri , $ options );
34+ return $ this ->requestWithCoverageId ($ method , $ uri , $ options );
3835 }
3936
4037 final protected function callApiWithKey (
@@ -55,14 +52,24 @@ final protected function getJsonResponsePayload(ResponseInterface $resp): array
5552
5653 final protected function callShortUrl (string $ shortCode , ?string $ userAgent = null ): ResponseInterface
5754 {
58- return self :: getClient ()-> request (self ::METHOD_GET , sprintf ('/%s ' , $ shortCode ), [
55+ return $ this -> requestWithCoverageId (self ::METHOD_GET , sprintf ('/%s ' , $ shortCode ), [
5956 RequestOptions::ALLOW_REDIRECTS => false ,
6057 RequestOptions::HEADERS => [
6158 'User-Agent ' => $ userAgent ,
6259 ],
6360 ]);
6461 }
6562
63+ private function requestWithCoverageId (string $ method , string $ uri , array $ options ): ResponseInterface
64+ {
65+ $ coverageId = CoverageHelper::resolveCoverageId (static ::class, $ this ->dataName ());
66+ return self ::getClient ()->request (
67+ $ method ,
68+ $ uri ,
69+ $ this ->optionsWithHeader ($ options , 'X-Coverage-Id ' , $ coverageId ),
70+ );
71+ }
72+
6673 private static function getClient (): ClientInterface
6774 {
6875 if (self ::$ client === null ) {
0 commit comments