Transactions   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 7
dl 0
loc 28
rs 10
c 0
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A create() 0 5 1
A __construct() 0 3 1
1
<?php
2
3
namespace PomeloPHP;
4
5
use PomeloPHP\Crypt\Signature;
6
use PomeloPHP\Model\Transaction;
7
8
class Transactions
9
{
10
    const ENDPOINT = 'transactions';
11
12
    /**
13
     * @var Client
14
     */
15
    private $client;
16
17
    /**
18
     * Payments constructor.
19
     * @param Client $client
20
     */
21
    public function __construct(Client $client)
22
    {
23
        $this->client = $client;
24
    }
25
26
    /**
27
     * @param array $json
28
     * @return mixed
29
     * @throws \GuzzleHttp\Exception\GuzzleException
30
     */
31
    public function create(array $json)
32
    {
33
        $transaction = (new Transaction())->fromArray($json);
34
        $json['signature'] = (new Signature($transaction, $this->client->getApiKey()))->sign();
35
        return $this->client->post(self::ENDPOINT, $json);
36
    }
37
}
38