AbstractRequest::setProxyPassword()   A
last analyzed

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
nc 1
cc 1
eloc 2
nop 1
crap 1
1
<?php
2
3
/*
4
 * WebMoney driver for the Omnipay PHP payment processing library
5
 *
6
 * @link      https://github.com/ck-developer/omnipay-payline
7
 * @package   omnipay-payline
8
 * @license   MIT
9
 * @copyright Copyright (c) 2016 Claude Khedhiri <[email protected]>
10
 */
11
12
namespace Omnipay\Payline\Message;
13
14
use Symfony\Component\HttpFoundation\Request as HttpRequest;
15
16
/**
17
 * Abstract Request.
18
 */
19
abstract class AbstractRequest extends \Omnipay\Common\Message\AbstractRequest
20
{
21
    /**
22
     * AbstractRequest constructor.
23
     *
24
     * @param \SoapClient $httpClient
25
     * @param HttpRequest $httpRequest
26
     */
27 33
    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...
28
    {
29 33
        $this->initialize();
30 33
        $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...
31 33
        $this->httpRequest = $httpRequest;
32 33
    }
33
34
    /**
35
     * @return string
36
     */
37 12
    public function getMerchantId()
38
    {
39 12
        return $this->getParameter('merchantId');
40
    }
41
42
    /**
43
     * @param string $merchantId
44
     *
45
     * @return $this
46
     */
47 33
    public function setMerchantId($merchantId)
48
    {
49 33
        return $this->setParameter('merchantId', $merchantId);
50
    }
51
52
    /**
53
     * @return string
54
     */
55 12
    public function getAccessKey()
56
    {
57 12
        return $this->getParameter('accessKey');
58
    }
59
60
    /**
61
     * @param string $accessKey
62
     *
63
     * @return $this
64
     */
65 33
    public function setAccessKey($accessKey)
66
    {
67 33
        return $this->setParameter('accessKey', $accessKey);
68
    }
69
70
    /**
71
     * @return string
72
     */
73 18
    public function getContractNumber()
74
    {
75 18
        return $this->getParameter('contractNumber');
76
    }
77
78
    /**
79
     * @param string $contractNumber
80
     *
81
     * @return $this
82
     */
83 33
    public function setContractNumber($contractNumber)
84
    {
85 33
        return $this->setParameter('contractNumber', $contractNumber);
86 2
    }
87
88
    /**
89
     * @return string
90
     */
91 12
    public function getProxyHost()
92
    {
93 12
        return $this->getParameter('proxyHost');
94
    }
95
96
    /**
97
     * @param string $proxyHost
98
     *
99
     * @return $this
100
     */
101 33
    public function setProxyHost($proxyHost)
102
    {
103 33
        return $this->setParameter('proxyHost', $proxyHost);
104
    }
105
106
    /**
107
     * @return string
108
     */
109 12
    public function getProxyPort()
110
    {
111 12
        return $this->getParameter('proxyPort');
112
    }
113
114
    /**
115
     * @param string $proxyPort
116
     *
117
     * @return $this
118
     */
119 33
    public function setProxyPort($proxyPort)
120
    {
121 33
        return $this->setParameter('proxyPort', $proxyPort);
122
    }
123
124
    /**
125
     * @return string
126
     */
127 12
    public function getProxyLogin()
128
    {
129 12
        return $this->getParameter('proxyLogin');
130
    }
131
132
    /**
133
     * @param string $proxyLogin
134
     *
135
     * @return $this
136
     */
137 33
    public function setProxyLogin($proxyLogin)
138
    {
139 33
        return $this->setParameter('proxyLogin', $proxyLogin);
140
    }
141
142
    /**
143
     * @return string
144
     */
145 12
    public function getProxyPassword()
146
    {
147 12
        return $this->getParameter('proxyPassword');
148
    }
149
150
    /**
151
     * @param string $proxyPassword
152
     *
153
     * @return $this
154
     */
155 33
    public function setProxyPassword($proxyPassword)
156
    {
157 33
        return $this->setParameter('proxyPassword', $proxyPassword);
158
    }
159
160
    public function getMethod()
161
    {
162
        return $this->getParameter('method');
163
    }
164
165 6
    protected function getBaseData()
166
    {
167
        $data = array(
168 6
            'payment' => array('contractNumber' => $this->getContractNumber()),
169 6
            'returnURL' => '',
170 6
            'cancelURL' => '',
171 6
            'notificationURL' => '',
172 4
        );
173 6
        return $data;
174
    }
175
176 9
    public function sendData($data)
177
    {
178 9
        $response = $this->httpClient->{$this->getMethod()}($data);
179
180 9
        return $this->createResponse($response);
181
    }
182
183
    /**
184
     * Get the response from request.
185
     *
186
     * @param \stdClass $data
187
     *
188
     * @return AbstractResponse
189
     */
190
    abstract protected function createResponse($data);
191
}
192