PaymentService   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 12
c 1
b 0
f 1
dl 0
loc 36
rs 10
wmc 5

3 Methods

Rating   Name   Duplication   Size   Complexity  
A create() 0 7 2
A list() 0 3 1
A get() 0 6 2
1
<?php
2
3
namespace App\Service\Hyperwallet;
4
5
use Exception;
6
use Hyperwallet\Exception\HyperwalletApiException;
7
use Hyperwallet\Model\Payment;
8
use Hyperwallet\Response\ListResponse;
9
10
/**
11
 * Class PaymentService
12
 * @package App\Service\Hyperwallet
13
 */
14
class PaymentService extends AbstractHyperwalletService
15
{
16
    /**
17
     * @return ListResponse
18
     *
19
     * @throws HyperwalletApiException
20
     */
21
    public function list(): ListResponse
22
    {
23
        return $this->client->listPayments();
24
    }
25
26
    /**
27
     * @param array $paymentDetails
28
     * @return Payment | Exception
29
     */
30
    public function create(array $paymentDetails)
31
    {
32
        try {
33
            $payment = new Payment($paymentDetails);
34
            return $this->client->createPayment($payment);
35
        } catch (Exception $exception) {
36
            return $exception;
37
        }
38
    }
39
40
    /**
41
     * @param string $paymentToken
42
     * @return Exception|Payment
43
     */
44
    public function get(string $paymentToken)
45
    {
46
        try {
47
            return $this->client->getPayment($paymentToken);
48
        } catch (Exception $exception) {
49
            return $exception;
50
        }
51
    }
52
}
53