Passed
Push — master ( cf05d8...5fb5a4 )
by Teye
01:45 queued 16s
created

BalanceListItem::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 1
eloc 2
c 1
b 0
f 1
nc 1
nop 2
dl 0
loc 4
ccs 3
cts 3
cp 1
crap 1
rs 10
1
<?php
2
3
namespace Level23\Dynadot\Dto;
4
5
final class BalanceListItem implements DtoInterface
6
{
7
    public string $currency;
8
    public string $amount;
9
10 1
    public function __construct(string $currency = '', string $amount = '')
11
    {
12 1
        $this->currency = $currency;
13 1
        $this->amount   = $amount;
14
    }
15
16 1
    public static function fromArray(array $data): self
17
    {
18 1
        return new self(
19 1
            $data['currency'] ?? '',
20 1
            $data['amount'] ?? ''
21 1
        );
22
    }
23
24
    /**
25
     * @return array<string, string>
26
     */
27
    public function jsonSerialize(): array
28
    {
29
        return [
30
            'currency' => $this->currency,
31
            'amount'   => $this->amount,
32
        ];
33
    }
34
}
35