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

BalanceListItem   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Test Coverage

Coverage 66.67%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 11
c 1
b 0
f 1
dl 0
loc 27
ccs 8
cts 12
cp 0.6667
rs 10
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A jsonSerialize() 0 5 1
A fromArray() 0 5 1
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