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.
Passed
Push — master ( 68460a...213420 )
by Miguel
42s queued 11s
created

SibsService::status()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Apoca\Sibs\Services;
4
5
use Apoca\Sibs\Brands\Card;
6
use Apoca\Sibs\Brands\Checkout;
7
use Apoca\Sibs\Brands\PaymentWithCard;
8
use Apoca\Sibs\Brands\Transaction;
9
use Apoca\Sibs\Contracts\PaymentInterface;
10
use Exception;
11
12
/**
13
 * Class SibsService
14
 *
15
 * @package Apoca\Sibs\Services
16
 */
17
class SibsService
18
{
19
    /**
20
     * @param array $request
21
     *
22
     * @return PaymentInterface
23
     * @throws Exception
24
     */
25
    public function checkout(array $request): PaymentInterface
26
    {
27
        switch (strtoupper($request['brand'])) {
28
            case 'MASTER':
29
            case 'AMEX':
30
            case 'VPAY':
31
            case 'MAESTRO':
32
            case 'VISADEBIT':
33
            case 'VISAELECTRON':
34
            case 'VISA':
35
                $payment = new PaymentWithCard(
36
                    $request['amount'],
37
                    strtoupper($request['currency']),
38
                    strtoupper($request['brand']),
39
                    strtoupper($request['type']),
40
                    new Card(
41
                        $request['number'],
42
                        $request['holder'],
43
                        $request['expiry_month'],
44
                        $request['expiry_year'],
45
                        $request['cvv']
46
                    )
47
                );
48
                break;
49
            case 'CHECKOUT':
50
                $payment = new Checkout($request['amount'], $request['currency'], $request['type']);
51
                break;
52
            case 'SIBS_MULTIBANCO':
53
                throw new \RuntimeException('SIBS_MULTIBANCO Service Payment not found.', 404);
54
                break;
55
            case 'DIRECTDEBIT_SEPA':
56
                throw new \RuntimeException('DIRECTDEBIT_SEPA Service Payment not found.', 404);
57
                break;
58
            case 'MBWAY':
59
                throw new \RuntimeException('MBWAY Service Payment not found.', 404);
60
                break;
61
            default:
62
                throw new \RuntimeException('Sibs Service Payment not found.', 404);
63
        }
64
65
        return $payment;
66
    }
67
68
    /**
69
     * Get payment status
70
     *
71
     * @param string $checkoutId
72
     *
73
     * @return object
74
     */
75
    public function status(string $checkoutId): object
76
    {
77
        return (new Transaction($checkoutId))->status();
78
    }
79
}
80