GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

InvoiceService::getInvoices()   B
last analyzed

Complexity

Conditions 4
Paths 5

Size

Total Lines 24
Code Lines 14

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 17
CRAP Score 4

Importance

Changes 0
Metric Value
dl 0
loc 24
ccs 17
cts 17
cp 1
rs 8.6845
c 0
b 0
f 0
cc 4
eloc 14
nc 5
nop 1
crap 4
1
<?php
2
3
namespace Speicher210\Monsum\Api\Service\Invoice;
4
5
use Speicher210\Monsum\Api\AbstractService;
6
7
/**
8
 * Service for invoices.
9
 */
10
class InvoiceService extends AbstractService
11
{
12
    /**
13
     * Get the invoices.
14
     *
15
     * @param Get\RequestData $requestData The request data.
16
     * @return Get\ApiResponse
17
     */
18 6
    public function getInvoices(Get\RequestData $requestData)
19
    {
20 6
        $request = new Get\Request($requestData);
21
22 6
        $apiResponse = $this->sendRequest($request, Get\ApiResponse::class);
23
        /** @var Get\Response $response */
24 6
        $response = $apiResponse->getResponse();
25 6
        foreach ($response->getInvoices() as $invoice) {
26 6
            $invoiceDate = $invoice->getInvoiceDate();
27 6
            if ($invoiceDate !== null) {
28 6
                $invoiceDate->setTime(0, 0, 0);
29 6
            }
30
31
            // We need to convert the due date to DateTime because of inconsistencies in the Monsum API response.
32 6
            $dueDate = $invoice->getDueDate();
33 6
            if ($dueDate !== null) {
34 6
                $dueDate = new \DateTime($dueDate);
35 6
                $dueDate->setTime(0, 0, 0);
36 6
                $invoice->setDueDate($dueDate);
37 6
            }
38 6
        }
39
40 6
        return $apiResponse;
41
    }
42
}
43