Completed
Push — master ( 905377...e98615 )
by Gregorio
02:42
created

AuthorizeRequest::getData()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 16
Code Lines 9

Duplication

Lines 16
Ratio 100 %

Code Coverage

Tests 10
CRAP Score 1

Importance

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