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

ConvertPaymentAction::supports()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 12

Importance

Changes 0
Metric Value
dl 0
loc 7
ccs 0
cts 4
cp 0
rs 9.4285
c 0
b 0
f 0
cc 3
eloc 5
nc 3
nop 1
crap 12
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 ConvertPaymentAction 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['TotalAmount'] = $payment->getTotalAmount();
29
        $details['TradeDesc'] = $payment->getDescription();
30
	$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...
31
32
        $request->setResult((array) $details);
33
    }
34
35
    /**
36
     * {@inheritdoc}
37
     */
38
    public function supports($request)
39
    {
40
        return
41
            $request instanceof Convert &&
42
            $request->getSource() instanceof PaymentInterface &&
43
            $request->getTo() == 'array';
44
    }
45
}
46