Completed
Push — master ( a67d05...c2561f )
by recca
10:25
created

StatusAction::execute()   B

Complexity

Conditions 6
Paths 7

Size

Total Lines 28
Code Lines 15

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 16
CRAP Score 6

Importance

Changes 0
Metric Value
dl 0
loc 28
ccs 16
cts 16
cp 1
rs 8.439
c 0
b 0
f 0
cc 6
eloc 15
nc 7
nop 1
crap 6
1
<?php
2
3
namespace PayumTW\Esunbank\Action;
4
5
use Payum\Core\Action\ActionInterface;
6
use Payum\Core\Bridge\Spl\ArrayObject;
7
use Payum\Core\Request\GetStatusInterface;
8
use Payum\Core\Exception\RequestNotSupportedException;
9
10
class StatusAction implements ActionInterface
11
{
12
    /**
13
     * {@inheritdoc}
14
     *
15
     * @param GetStatusInterface $request
16
     */
17 5
    public function execute($request)
18
    {
19 5
        RequestNotSupportedException::assertSupports($this, $request);
20
21 5
        $details = ArrayObject::ensureArrayObject($request->getModel());
22
23 5
        if (isset($details['RC']) === false) {
24 1
            $request->markNew();
25
26 1
            return;
27
        }
28
29 4
        if ($details['RC'] === '00') {
30 3
            if (isset($details['RRN']) === true) {
31
                isset($details['MACD']) === true || isset($details['TXNAMOUNT']) === true
32 2
                    ? $this->markCaptured()
0 ignored issues
show
Bug introduced by
The method markCaptured() does not seem to exist on object<PayumTW\Esunbank\Action\StatusAction>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
33
                    : $request->markCanceled();
34 1
35 1
                return;
36 3
            }
37 1
38
            $request->markRefunded();
39 1
40
            return;
41
        }
42 3
43 2
        $request->markFailed();
44
    }
45 1
46
    /**
47
     * {@inheritdoc}
48 1
     */
49
    public function supports($request)
50 1
    {
51
        return
52
            $request instanceof GetStatusInterface &&
53 1
            $request->getModel() instanceof \ArrayAccess;
54 1
    }
55
}
56