CancelTransactionAction   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 26
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 4

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 4
dl 26
loc 26
ccs 8
cts 8
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A execute() 8 8 1
A supports() 6 6 2

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 PayumTW\Ecpay\Action\Api;
4
5
use Payum\Core\Bridge\Spl\ArrayObject;
6
use PayumTW\Ecpay\Request\Api\CancelTransaction;
7
use Payum\Core\Exception\RequestNotSupportedException;
8
9 View Code Duplication
class CancelTransactionAction extends BaseApiAwareAction
10
{
11
    /**
12
     * {@inheritdoc}
13
     *
14
     * @param $request RefundTransaction
15
     */
16 1
    public function execute($request)
17
    {
18 1
        RequestNotSupportedException::assertSupports($this, $request);
19
20 1
        $details = ArrayObject::ensureArrayObject($request->getModel());
21
22 1
        $details->replace($this->api->cancelTransaction((array) $details));
23 1
    }
24
25
    /**
26
     * {@inheritdoc}
27
     */
28 1
    public function supports($request)
29
    {
30
        return
31 1
            $request instanceof CancelTransaction &&
32 1
            $request->getModel() instanceof \ArrayAccess;
33
    }
34
}
35