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\AdyenApi\Business\Converter; |
9
|
|
|
|
10
|
|
|
use Generated\Shared\Transfer\AdyenApiErrorResponseTransfer; |
|
|
|
|
11
|
|
|
use Generated\Shared\Transfer\AdyenApiResponseTransfer; |
|
|
|
|
12
|
|
|
use Psr\Http\Message\ResponseInterface; |
13
|
|
|
use SprykerEco\Zed\AdyenApi\AdyenApiConfig; |
14
|
|
|
use SprykerEco\Zed\AdyenApi\Dependency\Service\AdyenApiToUtilEncodingServiceInterface; |
15
|
|
|
|
16
|
|
|
abstract class AbstractConverter implements AdyenApiConverterInterface |
17
|
|
|
{ |
18
|
|
|
/** |
19
|
|
|
* @var \SprykerEco\Zed\AdyenApi\AdyenApiConfig |
20
|
|
|
*/ |
21
|
|
|
protected $config; |
22
|
|
|
|
23
|
|
|
/** |
24
|
|
|
* @var \SprykerEco\Zed\AdyenApi\Dependency\Service\AdyenApiToUtilEncodingServiceInterface |
25
|
|
|
*/ |
26
|
|
|
protected $encodingService; |
27
|
|
|
|
28
|
|
|
/** |
29
|
|
|
* @param \Generated\Shared\Transfer\AdyenApiResponseTransfer $responseTransfer |
30
|
|
|
* @param array $response |
31
|
|
|
* |
32
|
|
|
* @return \Generated\Shared\Transfer\AdyenApiResponseTransfer |
33
|
|
|
*/ |
34
|
|
|
abstract protected function updateResponseTransfer(AdyenApiResponseTransfer $responseTransfer, array $response): AdyenApiResponseTransfer; |
35
|
|
|
|
36
|
|
|
/** |
37
|
|
|
* @param \SprykerEco\Zed\AdyenApi\AdyenApiConfig $config |
38
|
|
|
* @param \SprykerEco\Zed\AdyenApi\Dependency\Service\AdyenApiToUtilEncodingServiceInterface $encodingService |
39
|
|
|
*/ |
40
|
|
|
public function __construct( |
41
|
|
|
AdyenApiConfig $config, |
42
|
|
|
AdyenApiToUtilEncodingServiceInterface $encodingService |
43
|
|
|
) { |
44
|
|
|
$this->config = $config; |
45
|
|
|
$this->encodingService = $encodingService; |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
/** |
49
|
|
|
* @param \Psr\Http\Message\ResponseInterface $response |
50
|
|
|
* @param bool $isSuccess |
51
|
|
|
* |
52
|
|
|
* @return \Generated\Shared\Transfer\AdyenApiResponseTransfer |
53
|
|
|
*/ |
54
|
|
|
public function convertToResponseTransfer(ResponseInterface $response, $isSuccess = true): AdyenApiResponseTransfer |
55
|
|
|
{ |
56
|
|
|
$responseBody = $this->encodingService->decodeJson($response->getBody(), true); |
57
|
|
|
$responseTransfer = new AdyenApiResponseTransfer(); |
58
|
|
|
$responseTransfer->setIsSuccess($isSuccess); |
59
|
|
|
|
60
|
|
|
if ($isSuccess) { |
61
|
|
|
return $this->updateResponseTransfer($responseTransfer, $responseBody); |
|
|
|
|
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
$error = (new AdyenApiErrorResponseTransfer())->fromArray($responseBody, true); |
65
|
|
|
$responseTransfer->setError($error); |
66
|
|
|
|
67
|
|
|
return $responseTransfer; |
68
|
|
|
} |
69
|
|
|
} |
70
|
|
|
|
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