PatchPriceListItem::getGuzzleOptions()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 8

Duplication

Lines 8
Ratio 100 %

Importance

Changes 0
Metric Value
dl 8
loc 8
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
namespace Fousky\Component\iDoklad\Functions\PriceListItems;
4
5
use Fousky\Component\iDoklad\Functions\iDokladAbstractFunction;
6
use Fousky\Component\iDoklad\Model\iDokladAbstractModel;
7
use Fousky\Component\iDoklad\Model\PriceListItems\PriceListApiModel;
8
use Fousky\Component\iDoklad\Model\PriceListItems\PriceListPatchModel;
9
10
/**
11
 * @see https://app.idoklad.cz/developer/Help/v2/cs/Api?apiId=PATCH-api-v2-PriceListItems-id
12
 *
13
 * @author Lukáš Brzák <[email protected]>
14
 */
15 View Code Duplication
class PatchPriceListItem 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 string $id */
18
    protected $id;
19
20
    /** @var PriceListPatchModel $data */
21
    protected $data;
22
23
    /**
24
     * @param string              $id
25
     * @param PriceListPatchModel $data
26
     *
27
     * @throws \Fousky\Component\iDoklad\Exception\InvalidModelException
28
     */
29
    public function __construct(string $id, PriceListPatchModel $data)
30
    {
31
        $this->id = $id;
32
        $this->data = $data;
33
34
        $this->validate($data);
35
    }
36
37
    /**
38
     * Get iDokladModelInterface class.
39
     *
40
     * @see iDokladModelInterface
41
     *
42
     * @return string
43
     */
44
    public function getModelClass(): string
45
    {
46
        return PriceListApiModel::class;
47
    }
48
49
    /**
50
     * GET|POST|PUT|DELETE e.g.
51
     *
52
     * @see iDoklad::request()
53
     *
54
     * @return string
55
     */
56
    public function getHttpMethod(): string
57
    {
58
        return 'PATCH';
59
    }
60
61
    /**
62
     * Return base URI, e.g. /invoices; /invoice/1/edit and so on.
63
     *
64
     * @see iDoklad::call()
65
     *
66
     * @return string
67
     */
68
    public function getUri(): string
69
    {
70
        return sprintf('PriceListItems/%s', $this->id);
71
    }
72
73
    /**
74
     * Vrátí seznam parametrů, které se předají GuzzleHttp\Client.
75
     *
76
     * @see \GuzzleHttp\Client::request()
77
     * @see iDoklad::call()
78
     *
79
     * @return array
80
     *
81
     * @throws \ReflectionException
82
     * @throws \InvalidArgumentException
83
     */
84
    public function getGuzzleOptions(): array
85
    {
86
        return [
87
            'json' => $this->data->toArray([
88
                iDokladAbstractModel::TOARRAY_REMOVE_NULLS => true,
89
            ]),
90
        ];
91
    }
92
}
93