StatusAction   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 5
lcom 0
cbo 3
dl 0
loc 38
ccs 14
cts 14
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A execute() 0 20 3
A supports() 0 6 2
1
<?php
2
3
namespace PayumTW\Ips\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 3
    public function execute($request)
18
    {
19 3
        RequestNotSupportedException::assertSupports($this, $request);
20
21 3
        $details = ArrayObject::ensureArrayObject($request->getModel());
22
23 3
        if (isset($details['RspCode']) === false) {
24 1
            $request->markNew();
25
26 1
            return;
27
        }
28
29 2
        if ($details['RspCode'] === '000000') {
30 1
            $request->markCaptured();
31
32 1
            return;
33
        }
34
35 1
        $request->markFailed();
36 1
    }
37
38
    /**
39
     * {@inheritdoc}
40
     */
41 3
    public function supports($request)
42
    {
43
        return
44 3
            $request instanceof GetStatusInterface &&
45 3
            $request->getModel() instanceof \ArrayAccess;
46
    }
47
}
48