Completed
Push — master ( 69d984...0eb511 )
by Claude
03:26
created

AbstractRequest::getKey()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 0
crap 1
1
<?php
2
3
namespace Omnipay\Payline\Message;
4
5
use Symfony\Component\HttpFoundation\Request as HttpRequest;
6
7
/**
8
 * Abstract Request
9
 */
10
abstract class AbstractRequest extends \Omnipay\Common\Message\AbstractRequest
11
{
12
    /**
13
     * AbstractRequest constructor.
14
     *
15
     * @param \SoapClient $httpClient
16
     * @param HttpRequest $httpRequest
17
     */
18 24
    public function __construct(\SoapClient $httpClient, HttpRequest $httpRequest)
0 ignored issues
show
Bug introduced by
You have injected the Request via parameter $httpRequest. This is generally not recommended as there might be multiple instances during a request cycle (f.e. when using sub-requests). Instead, it is recommended to inject the RequestStack and retrieve the current request each time you need it via getCurrentRequest().
Loading history...
19
    {
20 24
        $this->initialize();
21 24
        $this->httpClient = $httpClient;
0 ignored issues
show
Documentation Bug introduced by
It seems like $httpClient of type object<SoapClient> is incompatible with the declared type object<Guzzle\Http\ClientInterface> of property $httpClient.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
22 24
        $this->httpRequest = $httpRequest;
23 24
    }
24
25
    /**
26
     * @return string
27
     */
28 9
    public function getMerchantId()
29
    {
30 9
        return $this->getParameter('merchantId');
31
    }
32
33
    /**
34
     * @param string $merchantId
35
     * @return $this
36
     */
37 24
    public function setMerchantId($merchantId)
38
    {
39 24
        return $this->setParameter('merchantId', $merchantId);
40
    }
41
42
    /**
43
     * @return string
44
     */
45 11
    public function getAccessKey()
46
    {
47 11
        return $this->getParameter('accessKey');
48
    }
49
50
    /**
51
     * @param string $accessKey
52
     * @return $this
53
     */
54 24
    public function setAccessKey($accessKey)
55
    {
56 24
        return $this->setParameter('accessKey', $accessKey);
57
    }
58
59
    /**
60
     * @return string
61
     */
62 15
    public function getContractNumber()
63
    {
64 15
        return $this->getParameter('contractNumber');
65
    }
66
67
    /**
68
     * @param string $contractNumber
69
     * @return $this
70
     */
71 24
    public function setContractNumber($contractNumber)
72
    {
73 24
        return $this->setParameter('contractNumber', $contractNumber);
74
    }
75
76
    /**
77
     * @return string
78
     */
79 9
    public function getProxyHost()
80
    {
81 9
        return $this->getParameter('proxyHost');
82
    }
83
84
    /**
85
     * @param string $proxyHost
86
     * @return $this
87
     */
88 24
    public function setProxyHost($proxyHost)
89
    {
90 24
        return $this->setParameter('proxyHost', $proxyHost);
91
    }
92
93
    /**
94
     * @return string
95
     */
96 9
    public function getProxyPort()
97
    {
98 9
        return $this->getParameter('proxyPort');
99
    }
100
101
    /**
102
     * @param string $proxyPort
103
     * @return $this
104
     */
105 24
    public function setProxyPort($proxyPort)
106
    {
107 24
        return $this->setParameter('proxyPort', $proxyPort);
108
    }
109
110
    /**
111
     * @return string
112
     */
113 9
    public function getProxyLogin()
114
    {
115 9
        return $this->getParameter('proxyLogin');
116
    }
117
118
    /**
119
     * @param string $proxyLogin
120
     * @return $this
121
     */
122 24
    public function setProxyLogin($proxyLogin)
123
    {
124 24
        return $this->setParameter('proxyLogin', $proxyLogin);
125
    }
126
127
    /**
128
     * @return string
129
     */
130 9
    public function getProxyPassword()
131
    {
132 9
        return $this->getParameter('proxyPassword');
133
    }
134
135
    /**
136
     * @param string $proxyPassword
137
     * @return $this
138
     */
139 24
    public function setProxyPassword($proxyPassword)
140
    {
141 24
        return $this->setParameter('proxyPassword', $proxyPassword);
142
    }
143
144
    public function getMethod()
145
    {
146
        return $this->getParameter('method');
147
    }
148
149 6
    protected function getBaseData()
150
    {
151
        $data = array(
152 6
            'payment' => ['contractNumber' => $this->getContractNumber()],
153 6
            'returnURL' => '',
154 6
            'cancelURL' => '',
155 6
            'notificationURL' => '',
156 4
        );
157 6
        return $data;
158
    }
159
160 6
    public function sendData($data)
161
    {
162 6
        $response = $this->httpClient->{$this->getMethod()}($data);
163
164 6
        return $this->createResponse($response);
165
    }
166
167
    /**
168
     * Get the response from request.
169
     *
170
     * @param \stdClass $data
171
     *
172
     * @return AbstractResponse
173
     */
174
    abstract protected function createResponse($data);
175
}
176