GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

ConvertPaymentAction   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 4
eloc 13
dl 0
loc 28
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A execute() 0 16 1
A supports() 0 6 3
1
<?php
2
3
declare(strict_types=1);
4
5
namespace BitBag\SyliusBraintreePlugin\Action;
6
7
use Payum\Core\Action\ActionInterface;
8
use Payum\Core\Bridge\Spl\ArrayObject;
9
use Payum\Core\Exception\RequestNotSupportedException;
10
use Payum\Core\GatewayAwareInterface;
11
use Payum\Core\GatewayAwareTrait;
12
use Payum\Core\Model\PaymentInterface;
13
use Payum\Core\Request\Convert;
14
use Payum\Core\Request\GetCurrency;
15
16
final class ConvertPaymentAction implements ActionInterface, GatewayAwareInterface
17
{
18
    use GatewayAwareTrait;
19
20
    public function execute($request): void
21
    {
22
        RequestNotSupportedException::assertSupports($this, $request);
23
24
        /** @var PaymentInterface $payment */
25
        $payment = $request->getSource();
26
27
        $details = ArrayObject::ensureArrayObject($payment->getDetails());
28
29
        $this->gateway->execute($currency = new GetCurrency($payment->getCurrencyCode()));
30
31
        $details['amount'] = $payment->getTotalAmount() / 10 ** $currency->exp;
32
33
        $details['orderId'] = $payment->getNumber();
34
35
        $request->setResult((array) $details);
36
    }
37
38
    public function supports($request): bool
39
    {
40
        return
41
            $request instanceof Convert &&
42
            $request->getSource() instanceof PaymentInterface &&
43
            $request->getTo() == 'array'
44
        ;
45
    }
46
}
47