AbstractRequest   A
last analyzed

Complexity

Total Complexity 17

Size/Duplication

Total Lines 202
Duplicated Lines 4.46 %

Coupling/Cohesion

Components 2
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 17
lcom 2
cbo 1
dl 9
loc 202
ccs 39
cts 39
cp 1
rs 10
c 0
b 0
f 0

17 Methods

Rating   Name   Duplication   Size   Complexity  
A getPurse() 0 4 1
A setPurse() 0 4 1
A getCheckoutId() 0 4 1
A setCheckoutId() 0 4 1
A getSignAlgorithm() 0 4 1
A setSignAlgorithm() 0 4 1
A getSignKey() 0 4 1
A setSignKey() 0 4 1
A getTestKey() 0 4 1
A setTestKey() 0 4 1
A getReturnMethod() 0 4 1
A setReturnMethod() 0 4 1
A getCancelMethod() 0 4 1
A setCancelMethod() 0 4 1
A getNotifyMethod() 0 4 1
A setNotifyMethod() 0 4 1
A calculateSign() 9 10 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
/**
3
 * InterKassa driver for the Omnipay PHP payment processing library
4
 *
5
 * @link      https://github.com/hiqdev/omnipay-interkassa
6
 * @package   omnipay-interkassa
7
 * @license   MIT
8
 * @copyright Copyright (c) 2015-2017, HiQDev (http://hiqdev.com/)
9
 */
10
11
namespace Omnipay\InterKassa\Message;
12
13
/**
14
 * InterKassa Abstract Request.
15
 */
16
abstract class AbstractRequest extends \Omnipay\Common\Message\AbstractRequest
17
{
18
    /**
19
     * {@inheritdoc}
20
     */
21
    protected $zeroAmountAllowed = false;
22
23
    /**
24
     * @var string
25
     */
26
    protected $endpoint = 'https://sci.interkassa.com/';
27
28
    /**
29
     * Get the unified purse.
30
     *
31
     * @return string merchant purse
32
     */
33 2
    public function getPurse()
34
    {
35 2
        return $this->getCheckoutId();
36
    }
37
38
    /**
39
     * Set the unified purse.
40
     *
41
     * @param $value
42
     * @return self
43
     */
44 12
    public function setPurse($value)
45
    {
46 12
        return $this->setCheckoutId($value);
47
    }
48
49
    /**
50
     * Get the merchant purse.
51
     *
52
     * @return string merchant purse
53
     */
54 20
    public function getCheckoutId()
55
    {
56 20
        return $this->getParameter('checkoutId');
57
    }
58
59
    /**
60
     * Set the merchant purse.
61
     *
62
     * @param string $purse merchant purse
63
     *
64
     * @return self
65
     */
66 30
    public function setCheckoutId($purse)
67
    {
68 30
        return $this->setParameter('checkoutId', $purse);
69
    }
70
71
    /**
72
     * Get the sign algorithm.
73
     *
74
     * @return string sign algorithm
75
     */
76 15
    public function getSignAlgorithm()
77
    {
78 15
        return strtolower($this->getParameter('signAlgorithm'));
79
    }
80
81
    /**
82
     * Set the sign algorithm.
83
     *
84
     * @param string $value sign algorithm
85
     *
86
     * @return self
87
     */
88 30
    public function setSignAlgorithm($value)
89
    {
90 30
        return $this->setParameter('signAlgorithm', $value);
91
    }
92
93
    /**
94
     * Get the sign key.
95
     *
96
     * @return string sign key
97
     */
98 17
    public function getSignKey()
99
    {
100 17
        return $this->getParameter('signKey');
101
    }
102
103
    /**
104
     * Set the sign key.
105
     *
106
     * @param string $value sign key
107
     *
108
     * @return self
109
     */
110 30
    public function setSignKey($value)
111
    {
112 30
        return $this->setParameter('signKey', $value);
113
    }
114
115
    /**
116
     * Get the test key.
117
     *
118
     * @return string test key
119
     */
120 4
    public function getTestKey()
121
    {
122 4
        return $this->getParameter('testKey');
123
    }
124
125
    /**
126
     * Set the test key.
127
     *
128
     * @param string $value test key
129
     *
130
     * @return self
131
     */
132 20
    public function setTestKey($value)
133
    {
134 20
        return $this->setParameter('testKey', $value);
135
    }
136
137
    /**
138
     * Get the method for success return.
139
     *
140
     * @return mixed
141
     */
142 6
    public function getReturnMethod()
143
    {
144 6
        return $this->getParameter('returnMethod');
145
    }
146
147
    /**
148
     * Sets the method for success return.
149
     *
150
     * @param $returnMethod
151
     * @return \Omnipay\Common\Message\AbstractRequest
152
     */
153 6
    public function setReturnMethod($returnMethod)
154
    {
155 6
        return $this->setParameter('returnMethod', $returnMethod);
156
    }
157
158
    /**
159
     * Get the method for canceled payment return.
160
     *
161
     * @return mixed
162
     */
163 6
    public function getCancelMethod()
164
    {
165 6
        return $this->getParameter('cancelMethod');
166
    }
167
168
    /**
169
     * Sets the method for canceled payment return.
170
     *
171
     * @param $cancelMethod
172
     * @return \Omnipay\Common\Message\AbstractRequest
173
     */
174 6
    public function setCancelMethod($cancelMethod)
175
    {
176 6
        return $this->setParameter('cancelMethod', $cancelMethod);
177
    }
178
179
    /**
180
     * Get the method for request notify.
181
     *
182
     * @return mixed
183
     */
184 6
    public function getNotifyMethod()
185
    {
186 6
        return $this->getParameter('notifyMethod');
187
    }
188
189
    /**
190
     * Sets the method for request notify.
191
     *
192
     * @param $notifyMethod
193
     * @return \Omnipay\Common\Message\AbstractRequest
194
     */
195 6
    public function setNotifyMethod($notifyMethod)
196
    {
197 6
        return $this->setParameter('notifyMethod', $notifyMethod);
198
    }
199
200
    /**
201
     * Calculates sign for the $data.
202
     *
203
     * @param array $data
204
     * @param string $signKey
205
     * @return string
206
     */
207 7 View Code Duplication
    public function calculateSign($data, $signKey)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
208
    {
209 7
        unset($data['ik_sign']);
210 7
        ksort($data, SORT_STRING);
211 7
        array_push($data, $signKey);
212 7
        $signAlgorithm = $this->getSignAlgorithm();
213 7
        $signString = implode(':', $data);
214
215 7
        return base64_encode(hash($signAlgorithm, $signString, true));
216
    }
217
}
218