Passed
Pull Request — master (#28)
by Volodymyr
05:26
created

RiskCheckManager   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 83
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 32
dl 0
loc 83
rs 10
c 0
b 0
f 0
wmc 5

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A sendAddressCheckRequest() 0 21 2
A sendConsumerScoreRequest() 0 21 2
1
<?php
2
3
/**
4
 * MIT License
5
 * Use of this software requires acceptance of the Evaluation License Agreement. See LICENSE file.
6
 */
7
8
namespace SprykerEco\Zed\Payone\Business\RiskManager;
9
10
use Generated\Shared\Transfer\AddressCheckResponseTransfer;
0 ignored issues
show
Bug introduced by
The type Generated\Shared\Transfe...ssCheckResponseTransfer 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 Generated\Shared\Transfer\ConsumerScoreResponseTransfer;
0 ignored issues
show
Bug introduced by
The type Generated\Shared\Transfe...erScoreResponseTransfer 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 Generated\Shared\Transfer\QuoteTransfer;
0 ignored issues
show
Bug introduced by
The type Generated\Shared\Transfer\QuoteTransfer 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...
13
use SprykerEco\Zed\Payone\Business\Api\Adapter\AdapterInterface;
14
use SprykerEco\Zed\Payone\Business\RiskManager\Factory\RiskCheckFactoryInterface;
15
use SprykerEco\Zed\Payone\Business\RiskManager\Mapper\RiskCheckMapperInterface;
16
17
class RiskCheckManager implements RiskCheckManagerInterface
18
{
19
    /**
20
     * @var \SprykerEco\Zed\Payone\Business\RiskManager\Mapper\RiskCheckMapperInterface
21
     */
22
    protected $riskCheckMapper;
23
24
    /**
25
     * @var \SprykerEco\Zed\Payone\Business\Api\Adapter\AdapterInterface
26
     */
27
    protected $executionAdapter;
28
29
    /**
30
     * @var \SprykerEco\Zed\Payone\Business\RiskManager\Factory\RiskCheckFactoryInterface
31
     */
32
    protected $riskCheckFactory;
33
34
    /**
35
     * @param \SprykerEco\Zed\Payone\Business\RiskManager\Mapper\RiskCheckMapperInterface $riskCheckMapper
36
     * @param \SprykerEco\Zed\Payone\Business\Api\Adapter\AdapterInterface $executionAdapter
37
     * @param \SprykerEco\Zed\Payone\Business\RiskManager\Factory\RiskCheckFactoryInterface $riskCheckFactory
38
     */
39
    public function __construct(RiskCheckMapperInterface $riskCheckMapper, AdapterInterface $executionAdapter, RiskCheckFactoryInterface $riskCheckFactory)
40
    {
41
        $this->riskCheckMapper = $riskCheckMapper;
42
        $this->executionAdapter = $executionAdapter;
43
        $this->riskCheckFactory = $riskCheckFactory;
44
    }
45
46
    /**
47
     * @param \Generated\Shared\Transfer\QuoteTransfer $quoteTransfer
48
     *
49
     * @return \Generated\Shared\Transfer\AddressCheckResponseTransfer
50
     */
51
    public function sendAddressCheckRequest(QuoteTransfer $quoteTransfer): AddressCheckResponseTransfer
52
    {
53
        $requestContainer = $this->riskCheckMapper->mapAddressCheck($quoteTransfer);
54
        $response = $this->executionAdapter->sendRequest($requestContainer);
55
56
        $responseContainer = $this->riskCheckFactory->createAddressCheckResponseContainer();
57
        $responseContainer->init($response);
58
59
        $addressCheckResponseTransfer = new AddressCheckResponseTransfer();
60
        $addressCheckResponseTransfer->setStatus($responseContainer->getStatus());
61
        $addressCheckResponseTransfer->setStreetName($responseContainer->getStreetName());
0 ignored issues
show
Bug introduced by
The method getStreetName() does not exist on SprykerEco\Zed\Payone\Bu...stractResponseContainer. It seems like you code against a sub-type of SprykerEco\Zed\Payone\Bu...stractResponseContainer such as SprykerEco\Zed\Payone\Bu...rScoreResponseContainer or SprykerEco\Zed\Payone\Bu...sCheckResponseContainer. ( Ignorable by Annotation )

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

61
        $addressCheckResponseTransfer->setStreetName($responseContainer->/** @scrutinizer ignore-call */ getStreetName());
Loading history...
62
        $addressCheckResponseTransfer->setStreetNumber($responseContainer->getStreetNumber());
0 ignored issues
show
Bug introduced by
The method getStreetNumber() does not exist on SprykerEco\Zed\Payone\Bu...stractResponseContainer. It seems like you code against a sub-type of SprykerEco\Zed\Payone\Bu...stractResponseContainer such as SprykerEco\Zed\Payone\Bu...rScoreResponseContainer or SprykerEco\Zed\Payone\Bu...sCheckResponseContainer. ( Ignorable by Annotation )

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

62
        $addressCheckResponseTransfer->setStreetNumber($responseContainer->/** @scrutinizer ignore-call */ getStreetNumber());
Loading history...
63
        $addressCheckResponseTransfer->setZip($responseContainer->getZip());
0 ignored issues
show
Bug introduced by
The method getZip() does not exist on SprykerEco\Zed\Payone\Bu...stractResponseContainer. It seems like you code against a sub-type of SprykerEco\Zed\Payone\Bu...stractResponseContainer such as SprykerEco\Zed\Payone\Bu...rScoreResponseContainer or SprykerEco\Zed\Payone\Bu...sCheckResponseContainer. ( Ignorable by Annotation )

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

63
        $addressCheckResponseTransfer->setZip($responseContainer->/** @scrutinizer ignore-call */ getZip());
Loading history...
64
        $addressCheckResponseTransfer->setCity($responseContainer->getCity());
0 ignored issues
show
Bug introduced by
The method getCity() does not exist on SprykerEco\Zed\Payone\Bu...stractResponseContainer. It seems like you code against a sub-type of SprykerEco\Zed\Payone\Bu...stractResponseContainer such as SprykerEco\Zed\Payone\Bu...rScoreResponseContainer or SprykerEco\Zed\Payone\Bu...sCheckResponseContainer. ( Ignorable by Annotation )

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

64
        $addressCheckResponseTransfer->setCity($responseContainer->/** @scrutinizer ignore-call */ getCity());
Loading history...
65
        $addressCheckResponseTransfer->setSecstatus($responseContainer->getSecstatus());
0 ignored issues
show
Bug introduced by
The method getSecstatus() does not exist on SprykerEco\Zed\Payone\Bu...stractResponseContainer. It seems like you code against a sub-type of SprykerEco\Zed\Payone\Bu...stractResponseContainer such as SprykerEco\Zed\Payone\Bu...rScoreResponseContainer or SprykerEco\Zed\Payone\Bu...sCheckResponseContainer. ( Ignorable by Annotation )

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

65
        $addressCheckResponseTransfer->setSecstatus($responseContainer->/** @scrutinizer ignore-call */ getSecstatus());
Loading history...
66
67
        if (!is_null($responseContainer->getCustomermessage())) {
0 ignored issues
show
introduced by
The condition is_null($responseContainer->getCustomermessage()) is always false.
Loading history...
68
            $addressCheckResponseTransfer->setCustomerMessage($responseContainer->getCustomermessage());
69
        }
70
71
        return $addressCheckResponseTransfer;
72
    }
73
74
    /**
75
     * @param \Generated\Shared\Transfer\QuoteTransfer $quoteTransfer
76
     *
77
     * @return \Generated\Shared\Transfer\ConsumerScoreResponseTransfer
78
     */
79
    public function sendConsumerScoreRequest(QuoteTransfer $quoteTransfer): ConsumerScoreResponseTransfer
80
    {
81
        $requestContainer = $this->riskCheckMapper->mapConsumerScoreCheck($quoteTransfer);
82
83
        $response = $this->executionAdapter->sendRequest($requestContainer);
84
85
        $responseContainer = $this->riskCheckFactory->createConsumerScoreResponseContainer();
86
        $responseContainer->init($response);
87
88
        $consumerScoreResponseTransfer = new ConsumerScoreResponseTransfer();
89
        $consumerScoreResponseTransfer->setStatus($responseContainer->getStatus());
90
91
        if (!$responseContainer->isError()) {
92
            $consumerScoreResponseTransfer->setScore($responseContainer->getScore());
0 ignored issues
show
Bug introduced by
The method getScore() does not exist on SprykerEco\Zed\Payone\Bu...stractResponseContainer. It seems like you code against a sub-type of SprykerEco\Zed\Payone\Bu...stractResponseContainer such as SprykerEco\Zed\Payone\Bu...rScoreResponseContainer. ( Ignorable by Annotation )

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

92
            $consumerScoreResponseTransfer->setScore($responseContainer->/** @scrutinizer ignore-call */ getScore());
Loading history...
93
94
            return $consumerScoreResponseTransfer;
95
        }
96
97
        $consumerScoreResponseTransfer->setCustomerMessage($responseContainer->getCustomermessage());
98
99
        return $consumerScoreResponseTransfer;
100
    }
101
}
102