1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* Copyright © 2016-present Spryker Systems GmbH. All rights reserved. |
5
|
|
|
* Use of this software requires acceptance of the Evaluation License Agreement. See LICENSE file. |
6
|
|
|
*/ |
7
|
|
|
|
8
|
|
|
namespace SprykerEco\Service\AkeneoPim\Dependencies\External\Api\Adapter\HttpClient; |
9
|
|
|
|
10
|
|
|
use GuzzleHttp\Client as GuzzleHttpClient; |
|
|
|
|
11
|
|
|
use GuzzleHttp\ClientInterface; |
|
|
|
|
12
|
|
|
use GuzzleHttp\HandlerStack; |
|
|
|
|
13
|
|
|
use GuzzleHttp\Middleware; |
|
|
|
|
14
|
|
|
use GuzzleHttp\Utils; |
|
|
|
|
15
|
|
|
use Http\Promise\Promise as HttpPromise; |
|
|
|
|
16
|
|
|
use Psr\Http\Message\RequestInterface; |
|
|
|
|
17
|
|
|
use Psr\Http\Message\ResponseInterface; |
|
|
|
|
18
|
|
|
use function GuzzleHttp\choose_handler; |
|
|
|
|
19
|
|
|
|
20
|
|
|
abstract class AbstractHttpClient |
21
|
|
|
{ |
22
|
|
|
/** |
23
|
|
|
* @var \GuzzleHttp\ClientInterface |
24
|
|
|
*/ |
25
|
|
|
protected $client; |
26
|
|
|
|
27
|
|
|
public function __construct() |
28
|
|
|
{ |
29
|
|
|
$this->client = $this->buildClient(); |
30
|
|
|
} |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* @param \Psr\Http\Message\RequestInterface $request |
34
|
|
|
* |
35
|
|
|
* @return \Psr\Http\Message\ResponseInterface |
36
|
|
|
*/ |
37
|
|
|
public function sendRequest(RequestInterface $request): ResponseInterface |
38
|
|
|
{ |
39
|
|
|
return $this->client->send($request); |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* @param \Psr\Http\Message\RequestInterface $request |
44
|
|
|
* |
45
|
|
|
* @return \Http\Promise\Promise |
46
|
|
|
*/ |
47
|
|
|
public function sendAsyncRequest(RequestInterface $request): HttpPromise |
48
|
|
|
{ |
49
|
|
|
$promise = $this->client->sendAsync($request); |
50
|
|
|
|
51
|
|
|
return new Promise($promise, $request); |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
/** |
55
|
|
|
* @return \GuzzleHttp\ClientInterface |
56
|
|
|
*/ |
57
|
|
|
protected function buildClient(): ClientInterface |
58
|
|
|
{ |
59
|
|
|
$handlerStack = $this->createHandlerStack(); |
60
|
|
|
$handlerStack->push(Middleware::prepareBody(), 'prepare_body'); |
61
|
|
|
|
62
|
|
|
return new GuzzleHttpClient(['handler' => $handlerStack]); |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
/** |
66
|
|
|
* @return \GuzzleHttp\HandlerStack |
67
|
|
|
*/ |
68
|
|
|
protected function createHandlerStack(): HandlerStack |
69
|
|
|
{ |
70
|
|
|
if (method_exists(Utils::class, 'chooseHandler')) { |
71
|
|
|
return new HandlerStack(Utils::chooseHandler()); |
72
|
|
|
} |
73
|
|
|
|
74
|
|
|
return new HandlerStack(choose_handler()); |
|
|
|
|
75
|
|
|
} |
76
|
|
|
} |
77
|
|
|
|
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