Completed
Pull Request — master (#8)
by Laurens
01:46
created

PayoutInfoParser   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 15
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 6

Test Coverage

Coverage 0%

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A createFromResponse() 0 12 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace LauLamanApps\IzettleApi\Client\Finance;
6
7
use LauLamanApps\IzettleApi\API\Finance\Enum\Periodicity;
8
use LauLamanApps\IzettleApi\API\Finance\PayoutInfo;
9
use Money\Currency;
10
use Money\Money;
11
use Psr\Http\Message\ResponseInterface;
12
13
final class PayoutInfoParser
14
{
15
    public static function createFromResponse(ResponseInterface $response): PayoutInfo
16
    {
17
        $data = json_decode($response->getBody()->getContents(), true)['data'];
18
        $currency = new Currency($data['currencyId']);
19
20
        return new PayoutInfo(
21
            new Money($data['totalBalance'], $currency),
22
            new Money($data['nextPayoutAmount'], $currency),
23
            new Money($data['discountRemaining'], $currency),
24
            Periodicity::get($data['periodicity'])
25
        );
26
    }
27
}
28