PaymentService::get()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 2
eloc 4
c 1
b 0
f 1
nc 2
nop 1
dl 0
loc 6
rs 10
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