Passed
Push — master ( 511df1...0188a0 )
by Wagner
02:21 queued 12s
created

Certificates::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
c 1
b 0
f 0
nc 1
nop 3
dl 0
loc 4
rs 10
1
<?php
2
3
namespace WagnerMontanini\ApiNfeFasa;
4
5
6
/**
7
 * Class Certificates
8
 * @package WagnerMontanini\ApiNfeFasa
9
 */
10
class Certificates extends ApiNfeFasa
11
{
12
    /** @var array */
13
    private $headers;
0 ignored issues
show
introduced by
The private property $headers is not used, and could be removed.
Loading history...
14
15
    /**
16
     * Certificates constructor.
17
     * @param string $apiUrl
18
     * @param string $token
19
     * @param string $company_id
20
     */
21
    public function __construct(string $apiUrl, string $token, string $company_id)
22
    {
23
        parent::__construct($apiUrl, $token);
24
        $this->company = $company_id;
0 ignored issues
show
Bug Best Practice introduced by
The property company does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
25
    }
26
27
    /**
28
     * @param array|null $headers
29
     * @return Certificates
30
     */
31
    public function index(?array $headers): Certificates
32
    {
33
        $this->request(
34
            "GET",
35
            "/companies/{$this->company}/certificates",
36
            null,
37
            $headers
38
        );
39
40
        return $this;
41
    }
42
43
    /**
44
     * @param array $fields
45
     * @return Certificates
46
     */
47
    public function create(array $fields): Certificates
48
    {
49
        $this->request(
50
            "POST",
51
            "/companies/{$this->company}/certificates",
52
            $fields
53
        );
54
55
        return $this;
56
    }
57
58
    /**
59
     * @param string $certificate_id
60
     * @return Certificates
61
     */
62
    public function read(string $certificate_id): Certificates
63
    {
64
        $this->request(
65
            "GET",
66
            "/companies/{$this->company}/certificates/{$certificate_id}"
67
        );
68
69
        return $this;
70
    }
71
72
    /**
73
     * @param string $certificate_id
74
     * @return Certificates
75
     */
76
    public function delete(string $certificate_id): Certificates
77
    {
78
        $this->request(
79
            "DELETE",
80
            "/companies/{$this->company}/certificates/{$certificate_id}"
81
        );
82
83
        return $this;
84
    }
85
}