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

PurchaseHistoryParser   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 13
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 1
lcom 0
cbo 4
dl 0
loc 13
ccs 6
cts 6
cp 1
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A createFromResponse() 0 10 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