ProformaInvoiceFullyPay::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\ProformaInvoices;
4
5
use Fousky\Component\iDoklad\Functions\iDokladAbstractFunction;
6
use Fousky\Component\iDoklad\Model\Void\BooleanModel;
7
8
/**
9
 * @see https://app.idoklad.cz/developer/Help/v2/cs/Api?apiId=PUT-api-v2-ProformaInvoices-id-FullyPay_dateOfPayment_salesPosEquipmentId
10
 *
11
 * @author Lukáš Brzák <[email protected]>
12
 */
13 View Code Duplication
class ProformaInvoiceFullyPay 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...
14
{
15
    /** @var string $id */
16
    protected $id;
17
18
    /** @var array $urlParts */
19
    protected $urlParts = [];
20
21
    /**
22
     * @param string         $id
23
     * @param \DateTime|null $dateOfPayment
24
     * @param int|null       $salesPosEquipmentId
25
     */
26
    public function __construct(string $id, \DateTime $dateOfPayment = null, int $salesPosEquipmentId = null)
27
    {
28
        $this->id = $id;
29
30
        $parts = [];
31
        if ($dateOfPayment) {
32
            $parts['dateOfPayment'] = $dateOfPayment->format('Y-m-d H:i:s');
33
        }
34
        if (null !== $salesPosEquipmentId) {
35
            $parts['salesPosEquipmentId'] = $salesPosEquipmentId;
36
        }
37
38
        $this->urlParts = $parts;
39
    }
40
41
    /**
42
     * Get iDokladModelInterface class.
43
     *
44
     * @see iDokladModelInterface
45
     *
46
     * @return string
47
     */
48
    public function getModelClass(): string
49
    {
50
        return BooleanModel::class;
51
    }
52
53
    /**
54
     * GET|POST|PUT|DELETE e.g.
55
     *
56
     * @see iDoklad::request()
57
     *
58
     * @return string
59
     */
60
    public function getHttpMethod(): string
61
    {
62
        return 'PUT';
63
    }
64
65
    /**
66
     * Return base URI, e.g. /invoices; /invoice/1/edit and so on.
67
     *
68
     * @see iDoklad::call()
69
     *
70
     * @return string
71
     */
72
    public function getUri(): string
73
    {
74
        $uri = sprintf('ProformaInvoices/%s/FullyPay', $this->id);
75
76
        if (count($this->urlParts) > 0) {
77
            $uri .= '?'.http_build_query($this->urlParts);
78
        }
79
80
        return $uri;
81
    }
82
83
    /**
84
     * Vrátí seznam parametrů, které se předají GuzzleHttp\Client.
85
     *
86
     * @see \GuzzleHttp\Client::request()
87
     * @see iDoklad::call()
88
     *
89
     * @return array
90
     */
91
    public function getGuzzleOptions(): array
92
    {
93
        return [];
94
    }
95
}
96