ConvertPaymentLogisticsAction   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 4
dl 0
loc 37
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 1
A supports() 0 7 3
1
<?php
2
3
namespace PayumTW\Ecpay\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 ConvertPaymentLogisticsAction 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['MerchantTradeNo'] = $payment->getNumber();
28 1
        $details['ReceiverEmail'] = $payment->getClientEmail();
29 1
        $details['GoodsAmount'] = $payment->getTotalAmount();
30 1
        $details['TradeDesc'] = $payment->getDescription();
31
32 1
        $details['AllPayLogisticsID'] = $details['MerchantTradeNo'];
33
34 1
        $request->setResult((array) $details);
35 1
    }
36
37
    /**
38
     * {@inheritdoc}
39
     */
40 1
    public function supports($request)
41
    {
42
        return
43 1
            $request instanceof Convert &&
44 1
            $request->getSource() instanceof PaymentInterface &&
45 1
            $request->getTo() == 'array';
46
    }
47
}
48