Completed
Branch master (eebe0d)
by Gregorio
02:31 queued 50s
created

RefundRequest::getData()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 21
Code Lines 11

Duplication

Lines 21
Ratio 100 %

Code Coverage

Tests 12
CRAP Score 2

Importance

Changes 0
Metric Value
dl 21
loc 21
ccs 12
cts 12
cp 1
rs 9.3142
c 0
b 0
f 0
cc 2
eloc 11
nc 2
nop 0
crap 2
1
<?php
2
3
namespace Omnipay\Spreedly\Message;
4
5
use Omnipay\Spreedly\Message\Concerns\HasGateway;
6
use Omnipay\Spreedly\Message\Concerns\HasGatewaySpecificFields;
7
8
/**
9
 * @method Response send()
10
 */
11 View Code Duplication
class RefundRequest extends AbstractRequest
0 ignored issues
show
Duplication introduced by
This class 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...
12
{
13
    use HasGateway, HasGatewaySpecificFields;
14
15
    /**
16
     * @return array|null
17
     * @throws \Omnipay\Common\Exception\InvalidRequestException
18
     */
19 6
    public function getData()
20
    {
21 6
        $data = array();
22
23 6
        $this->validate('transactionReference');
24
25 6
        $data = $this->fillGatewaySpecificFields($data);
26
27 6
        if ($this->parameters->has('amount')) {
28 6
            $this->validate('amount', 'currency');
29
30 6
            $data = $this->fillExistingParameters($data, array(
31 6
                'amount' => 'amount_integer',
32 6
                'currency_code' => 'currency',
33 6
            ));
34
35 6
            return array('transaction' => $data);
36
        }
37
38 6
        return null;
39
    }
40
41
    /**
42
     * @return string
43
     */
44 6
    public function getEndpoint()
45
    {
46 6
        return $this->endpoint . 'transactions/' . $this->getTransactionReference() . '/credit';
47
    }
48
}
49