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

LibraryParser   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 6

Test Coverage

Coverage 100%

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A createFromResponse() 0 13 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace LauLamanApps\IzettleApi\Client\Product;
6
7
use LauLamanApps\IzettleApi\API\Product\Library;
8
use Psr\Http\Message\ResponseInterface;
9
use Ramsey\Uuid\Uuid;
10
11
final class LibraryParser
12
{
13 2
    public static function createFromResponse(ResponseInterface $response): Library
14
    {
15 2
        $data = json_decode($response->getBody()->getContents(), true);
16
17 2
        return new Library(
18 2
            Uuid::fromString($data['fromEventLogUuid']),
19 2
            Uuid::fromString($data['untilEventLogUuid']),
20 2
            ProductParser::parseArray($data['products']),
21 2
            DiscountParser::parseArray($data['discounts']),
22 2
            ProductParser::parseArray($data['deletedProducts']),
23 2
            DiscountParser::parseArray($data['deletedDiscounts'])
24
        );
25
    }
26
}
27