Passed
Pull Request — master (#32)
by Artem
07:12
created

Tax   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 10
c 1
b 0
f 1
dl 0
loc 37
rs 10
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A get() 0 5 1
A payments() 0 8 1
A history() 0 7 1
1
<?php
2
declare(strict_types=1);
3
4
namespace Shoman4eg\Nalog\Api;
5
6
use Psr\Http\Client\ClientExceptionInterface;
7
use Shoman4eg\Nalog\Model\Tax\HistoryRecords;
8
use Shoman4eg\Nalog\Model\Tax\PaymentRecords;
9
use Shoman4eg\Nalog\Model\Tax\Tax as TaxModel;
10
11
/**
12
 * @author Artem Dubinin <[email protected]>
13
 */
14
final class Tax extends BaseHttpApi
15
{
16
    /**
17
     * @throws ClientExceptionInterface
18
     */
19
    public function get(): TaxModel
20
    {
21
        $response = $this->httpGet('/taxes');
22
23
        return $this->hydrator->hydrate($response, TaxModel::class);
24
    }
25
26
    /**
27
     * @throws ClientExceptionInterface
28
     * @throws \JsonException
29
     */
30
    public function history(string $oktmo = null): HistoryRecords
31
    {
32
        $response = $this->httpPost('/taxes/history', [
33
            'oktmo' => $oktmo,
34
        ]);
35
36
        return $this->hydrator->hydrate($response, HistoryRecords::class);
37
    }
38
39
    /**
40
     * @throws ClientExceptionInterface
41
     * @throws \JsonException
42
     */
43
    public function payments(string $oktmo = null, bool $onlyPaid = false): PaymentRecords
44
    {
45
        $response = $this->httpPost('/taxes/payments', [
46
            'oktmo' => $oktmo,
47
            'onlyPaid' => $onlyPaid,
48
        ]);
49
50
        return $this->hydrator->hydrate($response, PaymentRecords::class);
51
    }
52
}
53