Completed
Push — master ( 2d17ac...dc6fd0 )
by Gregorio
02:39
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.006

Importance

Changes 0
Metric Value
dl 15
loc 15
ccs 9
cts 11
cp 0.8182
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 8
nc 1
nop 0
crap 1.006
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 4
    public function getData()
23
    {
24 4
        $this->validate('amount', 'currency');
25
26 4
        $data = $this->validateAndGetPaymentMethodData();
27
28 4
        $data = $this->fillGatewaySpecificFields($data);
29
30 4
        $data = $this->fillExistingParameters($data, [
31 4
            'amount' => 'amount_integer',
32 4
            'currency_code' => 'currency',
33 4
        ]);
34
35 4
        return ['transaction' => $data];
36
    }
37
38
    /**
39
     * @return string
40
     * @throws \Omnipay\Common\Exception\InvalidRequestException
41
     */
42 4
    public function getEndpoint()
43
    {
44 4
        return $this->getGatewayEndpoint() . 'purchase';
45
    }
46
}
47