Completed
Push — master ( 9c30d6...210d9b )
by Laurens
01:56
created

PayoutInfoBuilder   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 16
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 16
ccs 8
cts 8
cp 1
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A buildFromJson() 0 13 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 PayoutInfoBuilder implements PayoutInfoBuilderInterface
14
{
15 2
    public function buildFromJson(string $json): PayoutInfo
16
    {
17 2
        $data = json_decode($json, true)['data'];
18
19 2
        $currency = new Currency($data['currencyId']);
20
21 2
        return new PayoutInfo(
22 2
            new Money($data['totalBalance'], $currency),
23 2
            new Money($data['nextPayoutAmount'], $currency),
24 2
            new Money($data['discountRemaining'], $currency),
25 2
            Periodicity::get($data['periodicity'])
26
        );
27
    }
28
}
29