Completed
Push — master ( e41c6a...6a7f08 )
by Saurabh
03:07
created

Invoice   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 0
loc 34
ccs 8
cts 8
cp 1
rs 10
c 0
b 0
f 0
wmc 5
lcom 1
cbo 4

1 Method

Rating   Name   Duplication   Size   Complexity  
B get() 0 20 5
1
<?php
2
3
namespace Sausin\Signere;
4
5
use Carbon\Carbon;
6
use UnexpectedValueException;
7
8
class Invoice extends BaseClass
9
{
10
    /** The URI of the action */
11
    const URI = 'https://api.signere.no/api/Invoice';
12
13
    /**
14
     * Returns a list of invoice transactions for
15
     * the given year / month combination.
16
     *
17
     * @param  int    $year
18
     * @param  int    $month
19
     * @return object
20
     */
21 3
    public function get(int $year, int $month)
22
    {
23 3
        if ($year < 2015 || $year > Carbon::now()->year || $month < 1 || $month > 12) {
24 2
            throw new UnexpectedValueException('Invalid year or month');
25
        }
26
27
        // make the URL for this request
28 1
        $url = $this->transformUrl(sprintf('%s/%s/%s', self::URI, $year, $month));
29
30
        // get the headers for this request
31 1
        $headers = $this->headers->make('GET', $url);
32
33
        // get the response
34 1
        $response = $this->client->get($url, [
35 1
            'headers' => $headers,
36
        ]);
37
38
        // return the response
39 1
        return $response;
40
    }
41
}
42