RefundRequest::getData()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 16
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 10
CRAP Score 2

Importance

Changes 2
Bugs 1 Features 0
Metric Value
dl 0
loc 16
ccs 10
cts 10
cp 1
rs 9.4285
c 2
b 1
f 0
cc 2
eloc 9
nc 2
nop 0
crap 2
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 = [
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