Completed
Push — master ( fdca80...2de24b )
by Vladimir
08:54 queued 03:35
created

RefundRequest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 2
Bugs 1 Features 0
Metric Value
wmc 3
lcom 1
cbo 1
dl 0
loc 35
ccs 12
cts 12
cp 1
rs 10
c 2
b 1
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getData() 0 16 2
A getRequestToken() 0 4 1
1
<?php
2
3
namespace Omnipay\AcquiroPay\Message;
4
5
/**
6
 * Refund Request.
7
 *
8
 * @method Response send()
9
 */
10
class RefundRequest extends AbstractRequest
11
{
12
    /**
13
     * Get the raw data array for this message. The format of this varies from gateway to
14
     * gateway, but will usually be either an associative array, or a SimpleXMLElement.
15
     *
16
     * @return mixed
17
     */
18 9
    public function getData()
19
    {
20 9
        $this->validate('transactionReference');
21
22
        $data = array(
23 9
            'opcode'     => 1,
24 9
            'payment_id' => $this->getTransactionReference(),
25 9
            'token'      => $this->getRequestToken(),
26 9
        );
27
28 9
        if ($this->getAmount()) {
0 ignored issues
show
Bug Best Practice introduced by
The expression $this->getAmount() of type string|null is loosely compared to true; this is ambiguous if the string can be empty. You might want to explicitly use !== null instead.

In PHP, under loose comparison (like ==, or !=, or switch conditions), values of different types might be equal.

For string values, the empty string '' is a special case, in particular the following results might be unexpected:

''   == false // true
''   == null  // true
'ab' == false // false
'ab' == null  // false

// It is often better to use strict comparison
'' === false // false
'' === null  // false
Loading history...
29 3
            $data['amount'] = $this->getAmount();
30 3
        }
31
32 9
        return $data;
33
    }
34
35
    /**
36
     * Get a request token.
37
     *
38
     * @return string
39
     */
40 12
    public function getRequestToken()
41
    {
42 12
        return md5($this->getMerchantId().$this->getTransactionReference().$this->getAmount().$this->getSecretWord());
43
    }
44
}
45