CaptureRequest   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 38
Duplicated Lines 100 %

Coupling/Cohesion

Components 2
Dependencies 4

Test Coverage

Coverage 73.68%

Importance

Changes 0
Metric Value
wmc 4
lcom 2
cbo 4
dl 38
loc 38
ccs 14
cts 19
cp 0.7368
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getData() 21 21 3
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
8
/**
9
 * @method Response send()
10
 */
11 View Code Duplication
class CaptureRequest 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...
12
{
13
    use HasGateway, HasGatewaySpecificFields;
14
15
    /**
16
     * @return array|null
17
     * @throws \Omnipay\Common\Exception\InvalidRequestException
18
     */
19 4
    public function getData()
20
    {
21 4
        $data = array();
22
23 4
        $this->validate('transactionReference');
24
25 4
        $data = $this->fillGatewaySpecificFields($data);
26
27 4
        if ($this->parameters->has('amount')) {
28 4
            $this->validate('amount', 'currency');
29
30 4
            $data = $this->fillExistingParameters($data, array(
31 4
                'amount' => 'amount_integer',
32 4
                'currency_code' => 'currency',
33 4
            ));
34
35 4
            return array('transaction' => $data);
36
        }
37
38 2
        return count($data) ? $data : null;
39
    }
40
41
    /**
42
     * @return string
43
     */
44 4
    public function getEndpoint()
45
    {
46 4
        return $this->endpoint . 'transactions/' . $this->getTransactionReference() . '/capture';
47
    }
48
}
49