| 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\Business\Response\Converter; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  | use Generated\Shared\Transfer\CrefoPayApiErrorResponseTransfer; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  | use Generated\Shared\Transfer\CrefoPayApiResponseTransfer; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  | use SprykerEco\Zed\CrefoPayApi\Business\Response\Mapper\CrefoPayApiResponseMapperInterface; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  | use SprykerEco\Zed\CrefoPayApi\Business\Response\Validator\CrefoPayApiResponseValidatorInterface; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  | use SprykerEco\Zed\CrefoPayApi\CrefoPayApiConfig; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  | use SprykerEco\Zed\CrefoPayApi\Dependency\External\Guzzle\Response\CrefoPayApiGuzzleResponseInterface; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  | use SprykerEco\Zed\CrefoPayApi\Dependency\Service\CrefoPayApiToUtilEncodingServiceInterface; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 |  |  | class CrefoPayApiResponseConverter implements CrefoPayApiResponseConverterInterface | 
            
                                                                                                            
                            
            
                                    
            
            
                | 19 |  |  | { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 20 |  |  |     protected const EXTERNAL_ERROR_MESSAGE = 'CrefoPay service temporarily unavailable.'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 21 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 22 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 23 |  |  |      * @var \SprykerEco\Zed\CrefoPayApi\Dependency\Service\CrefoPayApiToUtilEncodingServiceInterface | 
            
                                                                                                            
                            
            
                                    
            
            
                | 24 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 25 |  |  |     protected $encodingService; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 26 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 27 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 28 |  |  |      * @var \SprykerEco\Zed\CrefoPayApi\Business\Response\Mapper\CrefoPayApiResponseMapperInterface | 
            
                                                                                                            
                            
            
                                    
            
            
                | 29 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 30 |  |  |     protected $responseMapper; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 31 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 32 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 33 |  |  |      * @var \SprykerEco\Zed\CrefoPayApi\Business\Response\Validator\CrefoPayApiResponseValidatorInterface | 
            
                                                                                                            
                            
            
                                    
            
            
                | 34 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 35 |  |  |     protected $responseValidator; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 36 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 37 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 38 |  |  |      * @var \SprykerEco\Zed\CrefoPayApi\CrefoPayApiConfig | 
            
                                                                                                            
                            
            
                                    
            
            
                | 39 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 40 |  |  |     protected $config; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 41 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 42 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 43 |  |  |      * @param \SprykerEco\Zed\CrefoPayApi\Dependency\Service\CrefoPayApiToUtilEncodingServiceInterface $encodingService | 
            
                                                                                                            
                            
            
                                    
            
            
                | 44 |  |  |      * @param \SprykerEco\Zed\CrefoPayApi\Business\Response\Mapper\CrefoPayApiResponseMapperInterface $responseMapper | 
            
                                                                                                            
                            
            
                                    
            
            
                | 45 |  |  |      * @param \SprykerEco\Zed\CrefoPayApi\Business\Response\Validator\CrefoPayApiResponseValidatorInterface $responseValidator | 
            
                                                                                                            
                            
            
                                    
            
            
                | 46 |  |  |      * @param \SprykerEco\Zed\CrefoPayApi\CrefoPayApiConfig $config | 
            
                                                                                                            
                            
            
                                    
            
            
                | 47 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 48 |  |  |     public function __construct( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 49 |  |  |         CrefoPayApiToUtilEncodingServiceInterface $encodingService, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 50 |  |  |         CrefoPayApiResponseMapperInterface $responseMapper, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 51 |  |  |         CrefoPayApiResponseValidatorInterface $responseValidator, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 52 |  |  |         CrefoPayApiConfig $config | 
            
                                                                                                            
                            
            
                                    
            
            
                | 53 |  |  |     ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 54 |  |  |         $this->encodingService = $encodingService; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 55 |  |  |         $this->responseMapper = $responseMapper; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 56 |  |  |         $this->responseValidator = $responseValidator; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 57 |  |  |         $this->config = $config; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 58 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 59 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 60 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 61 |  |  |      * @param \SprykerEco\Zed\CrefoPayApi\Dependency\External\Guzzle\Response\CrefoPayApiGuzzleResponseInterface $response | 
            
                                                                                                            
                            
            
                                    
            
            
                | 62 |  |  |      * @param bool $isSuccess | 
            
                                                                                                            
                            
            
                                    
            
            
                | 63 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 64 |  |  |      * @return \Generated\Shared\Transfer\CrefoPayApiResponseTransfer | 
            
                                                                                                            
                            
            
                                    
            
            
                | 65 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 66 |  |  |     public function convertToResponseTransfer( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 67 |  |  |         CrefoPayApiGuzzleResponseInterface $response, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 68 |  |  |         bool $isSuccess = true | 
            
                                                                                                            
                            
            
                                    
            
            
                | 69 |  |  |     ): CrefoPayApiResponseTransfer { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 70 |  |  |         $responseData = $this->encodingService->decodeJson($response->getResponseBody(), true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 71 |  |  |         $responseTransfer = $this->createResponseTransfer($isSuccess); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 72 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 73 |  |  |         if (!$isSuccess || !$this->responseValidator->validateResponse($response, $responseData)) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 74 |  |  |             return $this->updateResponseTransferWithError($responseTransfer, $responseData); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 75 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 76 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 77 |  |  |         return $this->responseMapper | 
            
                                                                                                            
                            
            
                                    
            
            
                | 78 |  |  |             ->mapResponseDataToResponseTransfer($responseData, $responseTransfer); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 79 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 80 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 81 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 82 |  |  |      * @param \Generated\Shared\Transfer\CrefoPayApiResponseTransfer $responseTransfer | 
            
                                                                                                            
                            
            
                                    
            
            
                | 83 |  |  |      * @param array|null $responseData | 
            
                                                                                                            
                            
            
                                    
            
            
                | 84 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 85 |  |  |      * @return \Generated\Shared\Transfer\CrefoPayApiResponseTransfer | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 86 |  |  |      */ | 
            
                                                                        
                            
            
                                    
            
            
                | 87 |  |  |     protected function updateResponseTransferWithError( | 
            
                                                                        
                            
            
                                    
            
            
                | 88 |  |  |         CrefoPayApiResponseTransfer $responseTransfer, | 
            
                                                                        
                            
            
                                    
            
            
                | 89 |  |  |         ?array $responseData | 
            
                                                                        
                            
            
                                    
            
            
                | 90 |  |  |     ): CrefoPayApiResponseTransfer { | 
            
                                                                        
                            
            
                                    
            
            
                | 91 |  |  |         $errorTransfer = (new CrefoPayApiErrorResponseTransfer()) | 
            
                                                                        
                            
            
                                    
            
            
                | 92 |  |  |             ->setMessage(static::EXTERNAL_ERROR_MESSAGE) | 
            
                                                                        
                            
            
                                    
            
            
                | 93 |  |  |             ->setErrorType($this->config->getApiErrorTypeExternal()); | 
            
                                                                        
                            
            
                                    
            
            
                | 94 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 95 |  |  |         if ($responseData !== null) { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                        
                            
            
                                    
            
            
                | 96 |  |  |             $errorTransfer->fromArray($responseData, true); | 
            
                                                                        
                            
            
                                    
            
            
                | 97 |  |  |         } | 
            
                                                                        
                            
            
                                    
            
            
                | 98 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 99 |  |  |         return $responseTransfer | 
            
                                                                        
                            
            
                                    
            
            
                | 100 |  |  |             ->setIsSuccess(false) | 
            
                                                                        
                            
            
                                    
            
            
                | 101 |  |  |             ->setError($errorTransfer); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 102 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 103 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 104 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 105 |  |  |      * @param bool $isSuccess | 
            
                                                                                                            
                            
            
                                    
            
            
                | 106 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 107 |  |  |      * @return \Generated\Shared\Transfer\CrefoPayApiResponseTransfer | 
            
                                                                                                            
                            
            
                                    
            
            
                | 108 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 109 |  |  |     protected function createResponseTransfer(bool $isSuccess): CrefoPayApiResponseTransfer | 
            
                                                                                                            
                            
            
                                    
            
            
                | 110 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 111 |  |  |         return (new CrefoPayApiResponseTransfer()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 112 |  |  |             ->setIsSuccess($isSuccess); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 113 |  |  |     } | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 114 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 115 |  |  |  | 
            
                        
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