RefundAction   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 28
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 6

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 6
dl 28
loc 28
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\Allpay\Action;
4
5
use Payum\Core\Request\Refund;
6
use Payum\Core\GatewayAwareTrait;
7
use Payum\Core\GatewayAwareInterface;
8
use Payum\Core\Action\ActionInterface;
9
use Payum\Core\Bridge\Spl\ArrayObject;
10
use PayumTW\Allpay\Request\Api\RefundTransaction;
11
use Payum\Core\Exception\RequestNotSupportedException;
12
13 View Code Duplication
class RefundAction implements ActionInterface, GatewayAwareInterface
14
{
15
    use GatewayAwareTrait;
16
17
    /**
18
     * {@inheritdoc}
19
     *
20
     * @param Refund $request
21
     */
22 1
    public function execute($request)
23
    {
24 1
        RequestNotSupportedException::assertSupports($this, $request);
25
26 1
        $details = ArrayObject::ensureArrayObject($request->getModel());
27
28 1
        $this->gateway->execute(new RefundTransaction($details));
29 1
    }
30
31
    /**
32
     * {@inheritdoc}
33
     */
34 1
    public function supports($request)
35
    {
36
        return
37 1
            $request instanceof Refund &&
38 1
            $request->getModel() instanceof \ArrayAccess;
39
    }
40
}
41