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

RiskCheckMapper::mapDefaultContainerParams()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 14
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 10
nc 1
nop 1
dl 0
loc 14
rs 9.9332
c 0
b 0
f 0
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\Mapper;
9
10
use Generated\Shared\Transfer\PayoneStandardParameterTransfer;
0 ignored issues
show
Bug introduced by
The type Generated\Shared\Transfe...andardParameterTransfer 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\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...
12
use SprykerEco\Shared\Payone\Dependency\ModeDetectorInterface;
13
use SprykerEco\Shared\Payone\PayoneApiConstants;
14
use SprykerEco\Zed\Payone\Business\Api\Request\Container\ContainerInterface;
15
use SprykerEco\Zed\Payone\Business\RiskManager\Factory\RiskCheckFactoryInterface;
16
use SprykerEco\Zed\Payone\PayoneConfig;
17
18
class RiskCheckMapper implements RiskCheckMapperInterface
19
{
20
    /**
21
     * @var \SprykerEco\Zed\Payone\Business\RiskManager\Factory\RiskCheckFactoryInterface
22
     */
23
    protected $riskCheckFactory;
24
25
    /**
26
     * @var \Generated\Shared\Transfer\PayoneStandardParameterTransfer
27
     */
28
    protected $standardParameters;
29
30
    /**
31
     * @var \SprykerEco\Shared\Payone\Dependency\ModeDetectorInterface
32
     */
33
    protected $modeDetector;
34
35
    /**
36
     * @var \SprykerEco\Zed\Payone\PayoneConfig
37
     */
38
    protected $payoneConfig;
39
40
    /**
41
     * @param \SprykerEco\Zed\Payone\Business\RiskManager\Factory\RiskCheckFactoryInterface $riskCheckFactory
42
     * @param \Generated\Shared\Transfer\PayoneStandardParameterTransfer $standardParameters
43
     * @param \SprykerEco\Shared\Payone\Dependency\ModeDetectorInterface $modeDetector
44
     * @param \SprykerEco\Zed\Payone\PayoneConfig $payoneConfig
45
     */
46
    public function __construct(
47
        RiskCheckFactoryInterface $riskCheckFactory,
48
        PayoneStandardParameterTransfer $standardParameters,
49
        ModeDetectorInterface $modeDetector,
50
        PayoneConfig $payoneConfig
51
    ) {
52
        $this->riskCheckFactory = $riskCheckFactory;
53
        $this->standardParameters = $standardParameters;
54
        $this->modeDetector = $modeDetector;
55
        $this->payoneConfig = $payoneConfig;
56
    }
57
58
    /**
59
     * @param \Generated\Shared\Transfer\QuoteTransfer $quoteTransfer
60
     *
61
     * @return \SprykerEco\Zed\Payone\Business\Api\Request\Container\ContainerInterface
62
     */
63
    public function mapAddressCheck(QuoteTransfer $quoteTransfer): ContainerInterface
64
    {
65
        /** @var \SprykerEco\Zed\Payone\Business\Api\Request\Container\AddressCheckContainer $container */
66
        $container = $this->riskCheckFactory->createAddressCheckContainer();
67
        $container = $this->mapDefaultContainerParams($container);
68
69
        $container->setFirstName($quoteTransfer->getBillingAddress()->getFirstName());
0 ignored issues
show
Bug introduced by
The method setFirstName() does not exist on SprykerEco\Zed\Payone\Bu...bstractRequestContainer. It seems like you code against a sub-type of SprykerEco\Zed\Payone\Bu...bstractRequestContainer such as SprykerEco\Zed\Payone\Bu...\ConsumerScoreContainer or SprykerEco\Zed\Payone\Bu...r\AddressCheckContainer or SprykerEco\Zed\Payone\Bu...\ManageMandateContainer. ( Ignorable by Annotation )

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

69
        $container->/** @scrutinizer ignore-call */ 
70
                    setFirstName($quoteTransfer->getBillingAddress()->getFirstName());
Loading history...
70
        $container->setLastName($quoteTransfer->getBillingAddress()->getLastName());
0 ignored issues
show
Bug introduced by
The method setLastName() does not exist on SprykerEco\Zed\Payone\Bu...bstractRequestContainer. It seems like you code against a sub-type of SprykerEco\Zed\Payone\Bu...bstractRequestContainer such as SprykerEco\Zed\Payone\Bu...\ConsumerScoreContainer or SprykerEco\Zed\Payone\Bu...r\AddressCheckContainer or SprykerEco\Zed\Payone\Bu...\ManageMandateContainer. ( Ignorable by Annotation )

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

70
        $container->/** @scrutinizer ignore-call */ 
71
                    setLastName($quoteTransfer->getBillingAddress()->getLastName());
Loading history...
71
        $container->setCompany($quoteTransfer->getBillingAddress()->getCompany());
0 ignored issues
show
Bug introduced by
The method setCompany() does not exist on SprykerEco\Zed\Payone\Bu...bstractRequestContainer. It seems like you code against a sub-type of SprykerEco\Zed\Payone\Bu...bstractRequestContainer such as SprykerEco\Zed\Payone\Bu...\ConsumerScoreContainer or SprykerEco\Zed\Payone\Bu...r\AddressCheckContainer or SprykerEco\Zed\Payone\Bu...\ManageMandateContainer. ( Ignorable by Annotation )

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

71
        $container->/** @scrutinizer ignore-call */ 
72
                    setCompany($quoteTransfer->getBillingAddress()->getCompany());
Loading history...
72
        $container->setCountry($quoteTransfer->getBillingAddress()->getIso2Code());
0 ignored issues
show
Bug introduced by
The method setCountry() does not exist on SprykerEco\Zed\Payone\Bu...bstractRequestContainer. It seems like you code against a sub-type of SprykerEco\Zed\Payone\Bu...bstractRequestContainer such as SprykerEco\Zed\Payone\Bu...\ConsumerScoreContainer or SprykerEco\Zed\Payone\Bu...r\AddressCheckContainer or SprykerEco\Zed\Payone\Bu...\ManageMandateContainer. ( Ignorable by Annotation )

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

72
        $container->/** @scrutinizer ignore-call */ 
73
                    setCountry($quoteTransfer->getBillingAddress()->getIso2Code());
Loading history...
73
        $container->setStreetName($quoteTransfer->getBillingAddress()->getAddress1());
0 ignored issues
show
Bug introduced by
The method setStreetName() does not exist on SprykerEco\Zed\Payone\Bu...bstractRequestContainer. It seems like you code against a sub-type of SprykerEco\Zed\Payone\Bu...bstractRequestContainer such as SprykerEco\Zed\Payone\Bu...\ConsumerScoreContainer or SprykerEco\Zed\Payone\Bu...r\AddressCheckContainer. ( Ignorable by Annotation )

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

73
        $container->/** @scrutinizer ignore-call */ 
74
                    setStreetName($quoteTransfer->getBillingAddress()->getAddress1());
Loading history...
74
        $container->setStreetNumber($quoteTransfer->getBillingAddress()->getAddress2());
0 ignored issues
show
Bug introduced by
The method setStreetNumber() does not exist on SprykerEco\Zed\Payone\Bu...bstractRequestContainer. It seems like you code against a sub-type of SprykerEco\Zed\Payone\Bu...bstractRequestContainer such as SprykerEco\Zed\Payone\Bu...\ConsumerScoreContainer or SprykerEco\Zed\Payone\Bu...r\AddressCheckContainer. ( Ignorable by Annotation )

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

74
        $container->/** @scrutinizer ignore-call */ 
75
                    setStreetNumber($quoteTransfer->getBillingAddress()->getAddress2());
Loading history...
75
        $container->setZip($quoteTransfer->getBillingAddress()->getZipCode());
0 ignored issues
show
Bug introduced by
The method setZip() does not exist on SprykerEco\Zed\Payone\Bu...bstractRequestContainer. It seems like you code against a sub-type of SprykerEco\Zed\Payone\Bu...bstractRequestContainer such as SprykerEco\Zed\Payone\Bu...\ConsumerScoreContainer or SprykerEco\Zed\Payone\Bu...r\AddressCheckContainer or SprykerEco\Zed\Payone\Bu...\ManageMandateContainer. ( Ignorable by Annotation )

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

75
        $container->/** @scrutinizer ignore-call */ 
76
                    setZip($quoteTransfer->getBillingAddress()->getZipCode());
Loading history...
76
        $container->setCity($quoteTransfer->getBillingAddress()->getCity());
0 ignored issues
show
Bug introduced by
The method setCity() does not exist on SprykerEco\Zed\Payone\Bu...bstractRequestContainer. It seems like you code against a sub-type of SprykerEco\Zed\Payone\Bu...bstractRequestContainer such as SprykerEco\Zed\Payone\Bu...\ConsumerScoreContainer or SprykerEco\Zed\Payone\Bu...r\AddressCheckContainer or SprykerEco\Zed\Payone\Bu...\ManageMandateContainer. ( Ignorable by Annotation )

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

76
        $container->/** @scrutinizer ignore-call */ 
77
                    setCity($quoteTransfer->getBillingAddress()->getCity());
Loading history...
77
        $container->setAddressCheckType($this->payoneConfig->getAddressCheckType());
0 ignored issues
show
Bug introduced by
The method setAddressCheckType() does not exist on SprykerEco\Zed\Payone\Bu...bstractRequestContainer. It seems like you code against a sub-type of SprykerEco\Zed\Payone\Bu...bstractRequestContainer such as SprykerEco\Zed\Payone\Bu...\ConsumerScoreContainer or SprykerEco\Zed\Payone\Bu...r\AddressCheckContainer. ( Ignorable by Annotation )

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

77
        $container->/** @scrutinizer ignore-call */ 
78
                    setAddressCheckType($this->payoneConfig->getAddressCheckType());
Loading history...
78
79
        return $container;
80
    }
81
82
    /**
83
     * @param \Generated\Shared\Transfer\QuoteTransfer $quoteTransfer
84
     *
85
     * @return \SprykerEco\Zed\Payone\Business\Api\Request\Container\ContainerInterface
86
     */
87
    public function mapConsumerScoreCheck(QuoteTransfer $quoteTransfer): ContainerInterface
88
    {
89
        /** @var \SprykerEco\Zed\Payone\Business\Api\Request\Container\ConsumerScoreContainer $container */
90
        $container = $this->riskCheckFactory->createConsumerScoreContainer();
91
        $container = $this->mapDefaultContainerParams($container);
92
93
        $container->setFirstName($quoteTransfer->getBillingAddress()->getFirstName());
94
        $container->setLastName($quoteTransfer->getBillingAddress()->getLastName());
95
        $container->setCompany($quoteTransfer->getBillingAddress()->getCompany());
96
        $container->setCountry($quoteTransfer->getBillingAddress()->getIso2Code());
97
        $container->setStreetName($quoteTransfer->getBillingAddress()->getAddress1());
98
        $container->setStreetNumber($quoteTransfer->getBillingAddress()->getAddress2());
99
        $container->setZip($quoteTransfer->getBillingAddress()->getZipCode());
100
        $container->setCity($quoteTransfer->getBillingAddress()->getCity());
101
        $container->setAddressCheckType($this->payoneConfig->getAddressCheckType());
102
        $container->setConsumerScoreType($this->payoneConfig->getConsumerScoreType());
0 ignored issues
show
Bug introduced by
The method setConsumerScoreType() does not exist on SprykerEco\Zed\Payone\Bu...bstractRequestContainer. It seems like you code against a sub-type of SprykerEco\Zed\Payone\Bu...bstractRequestContainer such as SprykerEco\Zed\Payone\Bu...\ConsumerScoreContainer. ( Ignorable by Annotation )

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

102
        $container->/** @scrutinizer ignore-call */ 
103
                    setConsumerScoreType($this->payoneConfig->getConsumerScoreType());
Loading history...
103
104
        return $container;
105
    }
106
107
    /**
108
     * @param \SprykerEco\Zed\Payone\Business\Api\Request\Container\ContainerInterface $container
109
     *
110
     * @return \SprykerEco\Zed\Payone\Business\Api\Request\Container\ContainerInterface
111
     */
112
    protected function mapDefaultContainerParams(ContainerInterface $container): ContainerInterface
113
    {
114
        /** @var \SprykerEco\Zed\Payone\Business\Api\Request\Container\AbstractRequestContainer $container */
115
        $container->setMid($this->standardParameters->getMid());
116
        $container->setAid($this->standardParameters->getAid());
117
        $container->setPortalid($this->standardParameters->getPortalId());
118
        $container->setKey(md5($this->standardParameters->getKey()));
119
        $container->setMode($this->modeDetector->getMode());
120
        $container->setIntegratorName(PayoneApiConstants::INTEGRATOR_NAME_SPRYKER);
121
        $container->setIntegratorVersion(PayoneApiConstants::INTEGRATOR_VERSION_3_0_0);
122
        $container->setSolutionName(PayoneApiConstants::SOLUTION_NAME_SPRYKER);
123
        $container->setSolutionVersion(PayoneApiConstants::SOLUTION_VERSION_3_0_0);
124
125
        return $container;
126
    }
127
}
128