Companies   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 85
Duplicated Lines 0 %

Importance

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

6 Methods

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