CreateTransactionAction::execute()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 11

Duplication

Lines 11
Ratio 100 %

Code Coverage

Tests 6
CRAP Score 1

Importance

Changes 0
Metric Value
dl 11
loc 11
rs 9.9
c 0
b 0
f 0
ccs 6
cts 6
cp 1
cc 1
nc 1
nop 1
crap 1
1
<?php
2
3
namespace PayumTW\Allpay\Action\Api;
4
5
use Payum\Core\Bridge\Spl\ArrayObject;
6
use Payum\Core\Reply\HttpPostRedirect;
7
use PayumTW\Allpay\Request\Api\CreateTransaction;
8
use Payum\Core\Exception\RequestNotSupportedException;
9
10 View Code Duplication
class CreateTransactionAction extends BaseApiAwareAction
11
{
12
    /**
13
     * {@inheritdoc}
14
     *
15
     * @param $request CreateTransaction
16
     */
17 1
    public function execute($request)
18
    {
19 1
        RequestNotSupportedException::assertSupports($this, $request);
20
21 1
        $details = ArrayObject::ensureArrayObject($request->getModel());
22
23 1
        throw new HttpPostRedirect(
24 1
            $this->api->getApiEndpoint(),
25 1
            $this->api->createTransaction((array) $details)
26
        );
27
    }
28
29
    /**
30
     * {@inheritdoc}
31
     */
32 1
    public function supports($request)
33
    {
34
        return
35 1
            $request instanceof CreateTransaction &&
36 1
            $request->getModel() instanceof \ArrayAccess;
37
    }
38
}
39