AbstractCall::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 4
c 1
b 0
f 0
nc 1
nop 4
dl 0
loc 10
rs 10
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\Client\Payone\ClientApi\Call;
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 Spryker\Service\UtilEncoding\UtilEncodingServiceInterface;
12
use SprykerEco\Client\Payone\ClientApi\HashGeneratorInterface;
13
use SprykerEco\Client\Payone\ClientApi\Request\AbstractRequest;
14
use SprykerEco\Shared\Payone\Dependency\ModeDetectorInterface;
15
16
abstract class AbstractCall implements CallInterface
17
{
18
    /**
19
     * @var \Generated\Shared\Transfer\PayoneStandardParameterTransfer
20
     */
21
    protected $standardParameter;
22
23
    /**
24
     * @var \SprykerEco\Client\Payone\ClientApi\HashGeneratorInterface
25
     */
26
    protected $hashGenerator;
27
28
    /**
29
     * @var \SprykerEco\Shared\Payone\Dependency\ModeDetectorInterface
30
     */
31
    protected $modeDetector;
32
33
    /**
34
     * @var \Spryker\Service\UtilEncoding\UtilEncodingServiceInterface
35
     */
36
    protected $utilEncodingService;
37
38
    /**
39
     * @param \Generated\Shared\Transfer\PayoneStandardParameterTransfer $standardParameterTransfer
40
     * @param \SprykerEco\Client\Payone\ClientApi\HashGeneratorInterface $hashGenerator
41
     * @param \SprykerEco\Shared\Payone\Dependency\ModeDetectorInterface $modeDetector
42
     * @param \Spryker\Service\UtilEncoding\UtilEncodingServiceInterface $utilEncodingService
43
     */
44
    public function __construct(
45
        PayoneStandardParameterTransfer $standardParameterTransfer,
46
        HashGeneratorInterface $hashGenerator,
47
        ModeDetectorInterface $modeDetector,
48
        UtilEncodingServiceInterface $utilEncodingService
49
    ) {
50
        $this->standardParameter = $standardParameterTransfer;
51
        $this->hashGenerator = $hashGenerator;
52
        $this->modeDetector = $modeDetector;
53
        $this->utilEncodingService = $utilEncodingService;
54
    }
55
56
    /**
57
     * @param \SprykerEco\Client\Payone\ClientApi\Request\AbstractRequest $container
58
     *
59
     * @return void
60
     */
61
    protected function applyStandardParameter(AbstractRequest $container): void
62
    {
63
        if ($container->getPortalid() === null) {
64
            $container->setPortalid($this->standardParameter->getPortalId());
65
        }
66
        if ($container->getAid() === null) {
67
            $container->setAid($this->standardParameter->getAid());
68
        }
69
        if ($container->getMid() === null) {
70
            $container->setMid($this->standardParameter->getMid());
71
        }
72
        if ($container->getEncoding() === null) {
73
            $container->setEncoding($this->standardParameter->getEncoding());
74
        }
75
        if ($container->getMode() === null) {
76
            $container->setMode($this->modeDetector->getMode());
77
        }
78
        if ($container->getLanguage() === null) {
79
            $container->setLanguage($this->standardParameter->getLanguage());
80
        }
81
        if ($container->getResponseType() === null) {
82
            $container->setResponseType($this->standardParameter->getResponseType());
83
        }
84
    }
85
86
    /**
87
     * @return \Generated\Shared\Transfer\PayoneStandardParameterTransfer
88
     */
89
    protected function getStandardParameter(): PayoneStandardParameterTransfer
90
    {
91
        return $this->standardParameter;
92
    }
93
94
    /**
95
     * @return \SprykerEco\Client\Payone\ClientApi\HashGeneratorInterface
96
     */
97
    protected function getHashGenerator(): HashGeneratorInterface
98
    {
99
        return $this->hashGenerator;
100
    }
101
102
    /**
103
     * @return \SprykerEco\Shared\Payone\Dependency\ModeDetectorInterface
104
     */
105
    protected function getModeDetector(): ModeDetectorInterface
106
    {
107
        return $this->modeDetector;
108
    }
109
}
110