CancelTransactionAction   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 28
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 28
loc 28
ccs 9
cts 9
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A execute() 10 10 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\Collect\Action\Api;
4
5
use Payum\Core\Bridge\Spl\ArrayObject;
6
use PayumTW\Collect\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->validateNotEmpty(['cust_order_no', 'order_amount']);
23
24 1
        $details->replace($this->api->cancelTransaction((array) $details));
25 1
    }
26
27
    /**
28
     * {@inheritdoc}
29
     */
30 1
    public function supports($request)
31
    {
32
        return
33 1
            $request instanceof CancelTransaction &&
34 1
            $request->getModel() instanceof \ArrayAccess;
35
    }
36
}
37