RecountSalesReceipt::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6

Duplication

Lines 6
Ratio 100 %

Importance

Changes 0
Metric Value
dl 6
loc 6
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
1
<?php
2
3
namespace Fousky\Component\iDoklad\Functions\SalesReceipts;
4
5
use Fousky\Component\iDoklad\Functions\iDokladAbstractFunction;
6
use Fousky\Component\iDoklad\Model\iDokladAbstractModel;
7
use Fousky\Component\iDoklad\Model\SalesReceipts\SalesReceiptApiModel;
8
use Fousky\Component\iDoklad\Model\SalesReceipts\SalesReceiptApiModelPost;
9
10
/**
11
 * @see https://app.idoklad.cz/developer/Help/v2/cs/Api?apiId=POST-api-v2-SalesReceipts-Recount
12
 *
13
 * @author Lukáš Brzák <[email protected]>
14
 */
15 View Code Duplication
class RecountSalesReceipt extends iDokladAbstractFunction
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
16
{
17
    /** @var SalesReceiptApiModelPost $data */
18
    protected $data;
19
20
    /**
21
     * @param SalesReceiptApiModelPost $data
22
     *
23
     * @throws \Fousky\Component\iDoklad\Exception\InvalidModelException
24
     */
25
    public function __construct(SalesReceiptApiModelPost $data)
26
    {
27
        $this->data = $data;
28
29
        $this->validate($data);
30
    }
31
32
    /**
33
     * Get iDokladModelInterface class.
34
     *
35
     * @see iDokladModelInterface
36
     *
37
     * @return string
38
     */
39
    public function getModelClass(): string
40
    {
41
        return SalesReceiptApiModel::class;
42
    }
43
44
    /**
45
     * GET|POST|PUT|DELETE e.g.
46
     *
47
     * @see iDoklad::request()
48
     *
49
     * @return string
50
     */
51
    public function getHttpMethod(): string
52
    {
53
        return 'POST';
54
    }
55
56
    /**
57
     * Return base URI, e.g. /invoices; /invoice/1/edit and so on.
58
     *
59
     * @see iDoklad::call()
60
     *
61
     * @return string
62
     */
63
    public function getUri(): string
64
    {
65
        return 'SalesReceipts/Recount';
66
    }
67
68
    /**
69
     * Vrátí seznam parametrů, které se předají GuzzleHttp\Client.
70
     *
71
     * @see \GuzzleHttp\Client::request()
72
     * @see iDoklad::call()
73
     *
74
     * @throws \ReflectionException
75
     * @throws \InvalidArgumentException
76
     *
77
     * @return array
78
     */
79
    public function getGuzzleOptions(): array
80
    {
81
        return [
82
            'json' => $this->data->toArray([
83
                iDokladAbstractModel::TOARRAY_REMOVE_NULLS => true,
84
            ]),
85
        ];
86
    }
87
}
88