Transactions::create()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 1
dl 0
loc 5
rs 10
c 0
b 0
f 0
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