Completed
Push — master ( f2b799...761b51 )
by Tobias
04:02
created

Invoice::create()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 6
Ratio 100 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 6
loc 6
ccs 3
cts 3
cp 1
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 1
crap 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Billogram\Api;
6
7
use Billogram\Exception\Domain\ValidationException;
8
use Billogram\Model\Invoice\Invoice as Model;
9
use Billogram\Model\Invoice\InvoiceCollection;
10
use Psr\Http\Message\ResponseInterface;
11
12
/**
13
 * @author Ibrahim Hizeoui <[email protected]>
14
 */
15 View Code Duplication
class Invoice extends HttpApi
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
16
{
17
    /**
18
     * @param array $param
19
     *
20
     * @return InvoiceCollection|ResponseInterface
21
     *
22
     * @see https://billogram.com/api/documentation#billogram_call_create
23
     */
24 1
    public function search(array $param = [])
25
    {
26 1
        $param = array_merge(['page' => 1, 'page_size' => 100], $param);
27 1
        $response = $this->httpGet('/billogram', $param);
28
29 1
        return $this->handleResponse($response, InvoiceCollection::class);
30
    }
31
32
    /**
33
     * @param string $invoiceId
34
     *
35
     * @return Model|ResponseInterface
36
     *
37
     * @see https://billogram.com/api/documentation#billogram_call_create
38
     */
39 2
    public function fetch(string $invoiceId)
40
    {
41 2
        $response = $this->httpGet('/billogram/'.$invoiceId);
42
43 2
        return $this->handleResponse($response, Model::class);
44
    }
45
46
    /**
47
     * @param array $invoice
48
     *
49
     * @return Model|ResponseInterface
50
     *
51
     * @see https://billogram.com/api/documentation#billogram_call_create
52
     *
53
     * @throws ValidationException
54
     */
55 1
    public function create(array $invoice)
56
    {
57 1
        $response = $this->httpPost('/billogram', $invoice);
58
59 1
        return $this->handleResponse($response, Model::class);
60
    }
61
62
    /**
63
     * @param string $invoiceId
64
     * @param array  $invoice
65
     *
66
     * @return Model|ResponseInterface
67
     *
68
     * @see https://billogram.com/api/documentation#billogram_call_create
69
     *
70
     * @throws ValidationException
71
     */
72 1
    public function update(string $invoiceId, array $invoice)
73
    {
74 1
        $response = $this->httpPut('/billogram/'.$invoiceId, $invoice);
75
76 1
        return $this->handleResponse($response, Model::class);
77
    }
78
}
79