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

InvoiceItemRepository   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 4
eloc 14
dl 0
loc 33
c 0
b 0
f 0
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getBaseUri() 0 3 1
A jsonToEntity() 0 3 1
A __construct() 0 3 1
A getSupportedFields() 0 12 1
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