__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 7

Duplication

Lines 7
Ratio 100 %

Importance

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