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

Invoice::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 4
nc 1
nop 3
dl 0
loc 6
ccs 5
cts 5
cp 1
crap 1
rs 9.4285
c 0
b 0
f 0
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