Completed
Pull Request — master (#10)
by
unknown
05:04
created

ConvertPaymentLogisticsAction::execute()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 19
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 1
Metric Value
dl 0
loc 19
ccs 0
cts 12
cp 0
rs 9.4285
c 1
b 0
f 1
cc 1
eloc 11
nc 1
nop 1
crap 2
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
    public function execute($request)
19
    {
20
        RequestNotSupportedException::assertSupports($this, $request);
21
22
        /** @var PaymentInterface $payment */
23
        $payment = $request->getSource();
24
25
        $details = ArrayObject::ensureArrayObject($payment->getDetails());
26
27
        $details['MerchantTradeNo'] = $payment->getNumber();
28
        $details['ReceiverEmail'] = $payment->getClientEmail();
29
        $details['GoodsAmount'] = $payment->getTotalAmount();
30
        $details['TradeDesc'] = $payment->getDescription();
31
	$details['Items'] = $payment->getItems();
0 ignored issues
show
Bug introduced by
The method getItems() does not seem to exist on object<Payum\Core\Model\PaymentInterface>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
32
33
        $details['AllPayLogisticsID'] = $details['MerchantTradeNo'];
34
35
        $request->setResult((array) $details);
36
    }
37
38
    /**
39
     * {@inheritdoc}
40
     */
41
    public function supports($request)
42
    {
43
        return
44
            $request instanceof Convert &&
45
            $request->getSource() instanceof PaymentInterface &&
46
            $request->getTo() == 'array';
47
    }
48
}
49