Passed
Push — feature/eco-2295/eco-2344-crea... ( 83a5ab...226db0 )
by Aleksey
01:13
created

AbstractConverter   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 48
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 2
eloc 10
dl 0
loc 48
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A convertToResponseTransfer() 0 8 1
A __construct() 0 6 1
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\Converter;
9
10
use Generated\Shared\Transfer\CrefoPayApiResponseTransfer;
0 ignored issues
show
Bug introduced by
The type Generated\Shared\Transfe...oPayApiResponseTransfer was not found. Maybe you did not declare it correctly or list all dependencies?

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:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
11
use Psr\Http\Message\ResponseInterface;
0 ignored issues
show
Bug introduced by
The type Psr\Http\Message\ResponseInterface was not found. Maybe you did not declare it correctly or list all dependencies?

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:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
12
use SprykerEco\Zed\CrefoPayApi\Business\Validator\Response\CrefoPayApiResponseValidatorInterface;
13
use SprykerEco\Zed\CrefoPayApi\Dependency\Service\CrefoPayApiToUtilEncodingServiceInterface;
14
15
abstract class AbstractConverter implements CrefoPayApiConverterInterface
16
{
17
    /**
18
     * @var \SprykerEco\Zed\CrefoPayApi\Business\Validator\Response\CrefoPayApiResponseValidatorInterface
19
     */
20
    protected $validator;
21
22
    /**
23
     * @var \SprykerEco\Zed\CrefoPayApi\Dependency\Service\CrefoPayApiToUtilEncodingServiceInterface
24
     */
25
    protected $encodingService;
26
27
    /**
28
     * @param \Generated\Shared\Transfer\CrefoPayApiResponseTransfer $responseTransfer
29
     * @param array $responseData
30
     *
31
     * @return \Generated\Shared\Transfer\CrefoPayApiResponseTransfer
32
     */
33
    abstract protected function updateResponseTransferWithApiCallResponse(
34
        CrefoPayApiResponseTransfer $responseTransfer,
35
        array $responseData
36
    ): CrefoPayApiResponseTransfer;
37
38
    /**
39
     * @param \SprykerEco\Zed\CrefoPayApi\Business\Validator\Response\CrefoPayApiResponseValidatorInterface $validator
40
     * @param \SprykerEco\Zed\CrefoPayApi\Dependency\Service\CrefoPayApiToUtilEncodingServiceInterface $encodingService
41
     */
42
    public function __construct(
43
        CrefoPayApiResponseValidatorInterface $validator,
44
        CrefoPayApiToUtilEncodingServiceInterface $encodingService
45
    ) {
46
        $this->validator = $validator;
47
        $this->encodingService = $encodingService;
48
    }
49
50
    /**
51
     * @param \Psr\Http\Message\ResponseInterface $response
52
     *
53
     * @return \Generated\Shared\Transfer\CrefoPayApiResponseTransfer
54
     */
55
    public function convertToResponseTransfer(ResponseInterface $response): CrefoPayApiResponseTransfer
56
    {
57
        $responseData = $this->encodingService->decodeJson($response->getBody(), true);
58
        $responseTransfer = new CrefoPayApiResponseTransfer();
59
        $responseTransfer = $this->updateResponseTransferWithApiCallResponse($responseTransfer, $responseData);
0 ignored issues
show
Bug introduced by
It seems like $responseData can also be of type null; however, parameter $responseData of SprykerEco\Zed\CrefoPayA...erWithApiCallResponse() does only seem to accept array, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

59
        $responseTransfer = $this->updateResponseTransferWithApiCallResponse($responseTransfer, /** @scrutinizer ignore-type */ $responseData);
Loading history...
60
        $this->validator->validate($responseTransfer);
61
62
        return $responseTransfer;
63
    }
64
}
65