|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* MIT License |
|
5
|
|
|
* For full license information, please view the LICENSE file that was distributed with this source code. |
|
6
|
|
|
*/ |
|
7
|
|
|
|
|
8
|
|
|
namespace SprykerEco\Zed\CrefoPayApi\Dependency\External\Guzzle; |
|
9
|
|
|
|
|
10
|
|
|
use GuzzleHttp\Client; |
|
|
|
|
|
|
11
|
|
|
use GuzzleHttp\Exception\RequestException; |
|
|
|
|
|
|
12
|
|
|
use GuzzleHttp\RequestOptions; |
|
|
|
|
|
|
13
|
|
|
use SprykerEco\Zed\CrefoPayApi\Dependency\External\Guzzle\Exception\CrefoPayApiGuzzleRequestException; |
|
14
|
|
|
use SprykerEco\Zed\CrefoPayApi\Dependency\External\Guzzle\Response\CrefoPayApiGuzzleResponse; |
|
15
|
|
|
use SprykerEco\Zed\CrefoPayApi\Dependency\External\Guzzle\Response\CrefoPayApiGuzzleResponseInterface; |
|
16
|
|
|
|
|
17
|
|
|
class CrefoPayApiGuzzleHttpClientAdapter implements CrefoPayApiGuzzleHttpClientAdapterInterface |
|
18
|
|
|
{ |
|
19
|
|
|
protected const DEFAULT_TIMEOUT = 45; |
|
20
|
|
|
protected const HEADER_CONTENT_TYPE_KEY = 'Content-Type'; |
|
21
|
|
|
protected const HEADER_CONTENT_TYPE_VALUE = 'application/x-www-form-urlencoded'; |
|
22
|
|
|
|
|
23
|
|
|
/** |
|
24
|
|
|
* @var \GuzzleHttp\Client |
|
25
|
|
|
*/ |
|
26
|
|
|
protected $guzzleHttpClient; |
|
27
|
|
|
|
|
28
|
|
|
public function __construct() |
|
29
|
|
|
{ |
|
30
|
|
|
$this->guzzleHttpClient = new Client([ |
|
31
|
|
|
RequestOptions::TIMEOUT => static::DEFAULT_TIMEOUT, |
|
32
|
|
|
RequestOptions::HEADERS => [ |
|
33
|
|
|
static::HEADER_CONTENT_TYPE_KEY => static::HEADER_CONTENT_TYPE_VALUE, |
|
34
|
|
|
], |
|
35
|
|
|
]); |
|
36
|
|
|
} |
|
37
|
|
|
|
|
38
|
|
|
/** |
|
39
|
|
|
* @param string $url |
|
40
|
|
|
* @param array $formParams |
|
41
|
|
|
* |
|
42
|
|
|
* @throws \SprykerEco\Zed\CrefoPayApi\Dependency\External\Guzzle\Exception\CrefoPayApiGuzzleRequestException |
|
43
|
|
|
* |
|
44
|
|
|
* @return \SprykerEco\Zed\CrefoPayApi\Dependency\External\Guzzle\Response\CrefoPayApiGuzzleResponseInterface |
|
45
|
|
|
*/ |
|
46
|
|
|
public function post(string $url, array $formParams = []): CrefoPayApiGuzzleResponseInterface |
|
47
|
|
|
{ |
|
48
|
|
|
try { |
|
49
|
|
|
$options = [ |
|
50
|
|
|
RequestOptions::FORM_PARAMS => $formParams, |
|
51
|
|
|
]; |
|
52
|
|
|
$response = $this->guzzleHttpClient->post($url, $options); |
|
53
|
|
|
} catch (RequestException $requestException) { |
|
54
|
|
|
$response = new CrefoPayApiGuzzleResponse($requestException->getResponse()->getBody()); |
|
55
|
|
|
throw new CrefoPayApiGuzzleRequestException( |
|
56
|
|
|
$response, |
|
57
|
|
|
$requestException->getMessage(), |
|
58
|
|
|
$requestException->getCode(), |
|
59
|
|
|
$requestException |
|
60
|
|
|
); |
|
61
|
|
|
} |
|
62
|
|
|
|
|
63
|
|
|
return new CrefoPayApiGuzzleResponse($response->getBody()); |
|
64
|
|
|
} |
|
65
|
|
|
} |
|
66
|
|
|
|
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