1 | <?php |
||
2 | |||
3 | namespace Postpay\HttpClients; |
||
4 | |||
5 | use GuzzleHttp\Client as GuzzleHttpClient; |
||
6 | use GuzzleHttp\Exception\RequestException; |
||
7 | use GuzzleHttp\RequestOptions; |
||
8 | |||
9 | use Postpay\Exceptions\PostpayException; |
||
10 | use Postpay\Http\Request; |
||
11 | use Postpay\Http\Response; |
||
12 | |||
13 | class GuzzleClient implements ClientInterface |
||
14 | { |
||
15 | /** |
||
16 | * @var GuzzleHttpClient The Guzzle client. |
||
17 | */ |
||
18 | protected $client; |
||
19 | |||
20 | /** |
||
21 | * @param GuzzleHttpClient|null The Guzzle client. |
||
0 ignored issues
–
show
|
|||
22 | */ |
||
23 | public function __construct(GuzzleHttpClient $client = null) |
||
24 | { |
||
25 | $this->client = $client ?: new GuzzleHttpClient(); |
||
26 | } |
||
27 | |||
28 | /** |
||
29 | * @inheritdoc |
||
30 | */ |
||
31 | public function send(Request $request, $timeout) |
||
32 | { |
||
33 | $options = [ |
||
34 | 'auth' => $request->getAuth(), |
||
35 | 'headers' => $request->getHeaders(), |
||
36 | 'http_errors' => false, |
||
37 | 'timeout' => $timeout, |
||
38 | 'connect_timeout' => 10, |
||
39 | RequestOptions::JSON => $request->json(), |
||
40 | ]; |
||
41 | try { |
||
42 | $response = $this->client->request( |
||
43 | $request->getMethod(), |
||
44 | $request->getUrl(), |
||
45 | $options |
||
46 | ); |
||
47 | } catch (RequestException $e) { |
||
48 | throw new PostpayException($e->getMessage(), $e->getCode()); |
||
49 | } |
||
50 | $headers = $response->getHeaders(); |
||
51 | $body = $response->getBody(); |
||
52 | $statusCode = $response->getStatusCode(); |
||
53 | return new Response($request, $statusCode, $headers, $body); |
||
54 | } |
||
55 | } |
||
56 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths