Invoices   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 86
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 26
c 1
b 0
f 0
dl 0
loc 86
rs 10
wmc 6

6 Methods

Rating   Name   Duplication   Size   Complexity  
A delete() 0 8 1
A update() 0 9 1
A __construct() 0 3 1
A index() 0 10 1
A create() 0 9 1
A read() 0 8 1
1
<?php
2
3
namespace BrennerSousa\CafeApi;
4
5
/**
6
 * Class Invoices
7
 * @package BrennerSousa\CafeApi
8
 */
9
class Invoices extends CafeApi
10
{
11
    /**
12
     * Invoices constructor
13
     * @param string $apiUrl
14
     * @param string $email
15
     * @param string $password
16
     */
17
    public function __construct(string $apiUrl, string $email, string $password)
18
    {
19
        parent::__construct($apiUrl, $email, $password);
20
    }
21
22
    /**
23
     * @param array|null $headers
24
     * @return Invoices
25
     */
26
    public function index(?array $headers): Invoices
27
    {
28
        $this->request(
29
            "GET",
30
            "/invoices",
31
            null,
32
            $headers
33
        );
34
35
        return $this;
36
    }
37
38
    /**
39
     * @param array $fields
40
     * @return Invoices
41
     */
42
    public function create(array $fields): Invoices
43
    {
44
        $this->request(
45
            "POST",
46
            "/invoices",
47
            $fields
48
        );
49
50
        return $this;
51
    }
52
53
    /**
54
     * @param int $invoiceId
55
     * @return Invoices
56
     */
57
    public function read(int $invoiceId): Invoices
58
    {
59
        $this->request(
60
            "GET",
61
            "/invoices/{$invoiceId}"
62
        );
63
64
        return $this;
65
    }
66
67
    /**
68
     * @param int $invoiceId
69
     * @param array $fields
70
     * @return Invoices
71
     */
72
    public function update(int $invoiceId, array $fields): Invoices
73
    {
74
        $this->request(
75
            "PUT",
76
            "/invoices/{$invoiceId}",
77
            $fields
78
        );
79
80
        return $this;
81
    }
82
83
    /**
84
     * @param int $invoiceId
85
     * @return Invoices
86
     */
87
    public function delete(int $invoiceId): Invoices
88
    {
89
        $this->request(
90
            "DELETE",
91
            "/invoices/{$invoiceId}"
92
        );
93
94
        return $this;
95
    }
96
}