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

AuthorizeRequest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 35
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 4

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 4
dl 35
loc 35
ccs 11
cts 11
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getData() 15 15 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\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 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...
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() . 'authorize';
45
    }
46
}
47