UpdateDocumentAddress::getHttpMethod()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 4
Ratio 100 %

Importance

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