CreateTransactionAction   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 5

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 5
dl 0
loc 36
ccs 15
cts 15
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A execute() 0 18 2
A supports() 0 6 2
1
<?php
2
3
namespace PayumTW\Ezship\Action\Api;
4
5
use Payum\Core\Bridge\Spl\ArrayObject;
6
use Payum\Core\Reply\HttpPostRedirect;
7
use PayumTW\Ezship\Request\Api\CreateTransaction;
8
use Payum\Core\Exception\RequestNotSupportedException;
9
10
class CreateTransactionAction extends BaseApiAwareAction
11
{
12
    /**
13
     * {@inheritdoc}
14
     *
15
     * @param $request CreateTransaction
16
     */
17 2
    public function execute($request)
18
    {
19 2
        RequestNotSupportedException::assertSupports($this, $request);
20
21 2
        $details = ArrayObject::ensureArrayObject($request->getModel());
22
23 2
        if (empty($details['order_amount']) === true) {
24 1
            throw new HttpPostRedirect(
25 1
                $this->api->getApiEndpoint('cvs'),
26 1
                $this->api->createCvsMapTransaction((array) $details)
27 1
            );
28
        }
29
30 1
        throw new HttpPostRedirect(
31 1
            $this->api->getApiEndpoint('capture'),
32 1
            $this->api->createTransaction((array) $details)
33 1
        );
34
    }
35
36
    /**
37
     * {@inheritdoc}
38
     */
39 2
    public function supports($request)
40
    {
41
        return
42 2
            $request instanceof CreateTransaction &&
43 2
            $request->getModel() instanceof \ArrayAccess;
44
    }
45
}
46