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

PurchaseRequest::getData()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 15
Code Lines 8

Duplication

Lines 15
Ratio 100 %

Code Coverage

Tests 9
CRAP Score 1

Importance

Changes 0
Metric Value
dl 15
loc 15
ccs 9
cts 9
cp 1
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 8
nc 1
nop 0
crap 1
1
<?php
2
3
namespace Omnipay\Spreedly\Message;
4
5
use Omnipay\Spreedly\Message\Concerns\HasGateway;
6
use Omnipay\Spreedly\Message\Concerns\HasGatewaySpecificFields;
7
use Omnipay\Spreedly\Message\Concerns\HasPaymentMethodData;
8
9
/**
10
 * @method Response send()
11
 */
12 View Code Duplication
class PurchaseRequest 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...
13
{
14
    use HasGateway, HasPaymentMethodData, HasGatewaySpecificFields;
15
16
    /**
17
     * @return array
18
     * @throws \Omnipay\Common\Exception\InvalidCreditCardException
19
     * @throws \Omnipay\Common\Exception\InvalidRequestException
20
     * @throws \Omnipay\Spreedly\Exception\InvalidPaymentMethodException
21
     */
22 6
    public function getData()
23
    {
24 6
        $this->validate('amount', 'currency');
25
26 6
        $data = $this->validateAndGetPaymentMethodData();
27
28 6
        $data = $this->fillGatewaySpecificFields($data);
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
    /**
39
     * @return string
40
     * @throws \Omnipay\Common\Exception\InvalidRequestException
41
     */
42 6
    public function getEndpoint()
43
    {
44 6
        return $this->getGatewayEndpoint() . 'purchase';
45
    }
46
}
47