Passed
Push — master ( 0676a7...01ab94 )
by Artem
11:54
created

InvoiceItemRepository::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 3
c 0
b 0
f 0
rs 10
cc 1
nc 1
nop 2
1
<?php
2
3
// ---------------------------------------------------------------------
4
//
5
//  Copyright (C) 2018-2024 Artem Rodygin
6
//
7
//  You should have received a copy of the MIT License along with
8
//  this file. If not, see <https://opensource.org/licenses/MIT>.
9
//
10
// ---------------------------------------------------------------------
11
12
namespace Linode\Account\Repository;
13
14
use Linode\Account\InvoiceItem;
15
use Linode\Account\InvoiceItemRepositoryInterface;
16
use Linode\Entity;
17
use Linode\Internal\AbstractRepository;
18
use Linode\LinodeClient;
19
20
/**
21
 * @codeCoverageIgnore This class was autogenerated.
22
 */
23
class InvoiceItemRepository extends AbstractRepository implements InvoiceItemRepositoryInterface
24
{
25
    /**
26
     * @param int $invoiceId The ID of the Invoice.
27
     */
28
    public function __construct(LinodeClient $client, protected int $invoiceId)
29
    {
30
        parent::__construct($client);
31
    }
32
33
    protected function getBaseUri(): string
34
    {
35
        return sprintf('/account/invoices/%s/items', $this->invoiceId);
36
    }
37
38
    protected function getSupportedFields(): array
39
    {
40
        return [
41
            InvoiceItem::FIELD_LABEL,
42
            InvoiceItem::FIELD_FROM,
43
            InvoiceItem::FIELD_TO,
44
            InvoiceItem::FIELD_AMOUNT,
45
            InvoiceItem::FIELD_TAX,
46
            InvoiceItem::FIELD_TOTAL,
47
            InvoiceItem::FIELD_QUANTITY,
48
            InvoiceItem::FIELD_UNITPRICE,
49
            InvoiceItem::FIELD_TYPE,
50
        ];
51
    }
52
53
    protected function jsonToEntity(array $json): Entity
54
    {
55
        return new InvoiceItem($this->client, $json);
56
    }
57
}
58