AuthorizeRequest   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 37
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 5

Test Coverage

Coverage 76.47%

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 5
dl 37
loc 37
ccs 13
cts 17
cp 0.7647
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getData() 17 17 1
A getEndpoint() 4 4 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

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
            'retain_on_success' => 'retain_on_success',
36 6
        ));
37
38 6
        return array('transaction' => $data);
39
    }
40
41
    /**
42
     * @return string
43
     * @throws \Omnipay\Common\Exception\InvalidRequestException
44
     */
45 6
    public function getEndpoint()
46
    {
47 6
        return $this->getGatewayEndpoint() . 'authorize';
48
    }
49
}
50