AbstractCall::getModeDetector()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

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