ConvertPaymentAction::execute()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 14
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 8
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 14
ccs 8
cts 8
cp 1
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 7
nc 1
nop 1
crap 1
1
<?php
2
3
namespace PayumTW\Esunbank\Action;
4
5
use Payum\Core\Request\Convert;
6
use Payum\Core\Action\ActionInterface;
7
use Payum\Core\Bridge\Spl\ArrayObject;
8
use Payum\Core\Model\PaymentInterface;
9
use Payum\Core\Exception\RequestNotSupportedException;
10
11
class ConvertPaymentAction implements ActionInterface
12
{
13
    /**
14
     * {@inheritdoc}
15
     *
16
     * @param Convert $request
17
     */
18 1
    public function execute($request)
19
    {
20 1
        RequestNotSupportedException::assertSupports($this, $request);
21
22
        /** @var PaymentInterface $payment */
23 1
        $payment = $request->getSource();
24
25 1
        $details = ArrayObject::ensureArrayObject($payment->getDetails());
26
27 1
        $details['ONO'] = strtoupper($payment->getNumber());
28 1
        $details['TA'] = $payment->getTotalAmount();
29
30 1
        $request->setResult((array) $details);
31 1
    }
32
33
    /**
34
     * {@inheritdoc}
35
     */
36 1
    public function supports($request)
37
    {
38
        return
39 1
            $request instanceof Convert &&
40 1
            $request->getSource() instanceof PaymentInterface &&
41 1
            $request->getTo() == 'array';
42
    }
43
}
44