Passed
Push — master ( 9ff768...b736eb )
by Laurens
02:33
created

PurchaseHistoryParser::createFromResponse()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 10
ccs 6
cts 6
cp 1
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 6
nc 1
nop 1
crap 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace LauLamanApps\IzettleApi\Client\Purchase;
6
7
use LauLamanApps\IzettleApi\API\Purchase\PurchaseHistory;
8
use Psr\Http\Message\ResponseInterface;
9
10
final class PurchaseHistoryParser
11
{
12 2
    public static function createFromResponse(ResponseInterface $response): PurchaseHistory
13
    {
14 2
        $data = json_decode($response->getBody()->getContents(), true);
15
16 2
        return new PurchaseHistory(
17 2
            $data['firstPurchaseHash'],
18 2
            $data['lastPurchaseHash'],
19 2
            PurchaseParser::parseArray($data['purchases'])
20
        );
21
    }
22
}
23