Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
6 / 6
100.00% covered (success)
100.00%
2 / 2
CRAP
100.00% covered (success)
100.00%
1 / 1
BalanceHistoryPointData
100.00% covered (success)
100.00%
6 / 6
100.00% covered (success)
100.00%
2 / 2
2
100.00% covered (success)
100.00%
1 / 1
 __construct
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
1 / 1
1
 jsonSerialize
100.00% covered (success)
100.00%
4 / 4
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2
3declare(strict_types=1);
4
5namespace App\Domain\Account\Data;
6
7use App\Support\Row;
8use JsonSerializable;
9
10/**
11 * Represents a single balance history data point for charting.
12 */
13final class BalanceHistoryPointData implements JsonSerializable
14{
15    public readonly string $date;
16
17    public readonly float $value;
18
19    /**
20     * @param array<mixed> $data
21     */
22    public function __construct(array $data)
23    {
24        $this->date = Row::string($data, 'date');
25        $this->value = Row::float($data, 'value');
26    }
27
28    /**
29     * @return array{date: string, value: float}
30     */
31    public function jsonSerialize(): array
32    {
33        return [
34            'date' => $this->date,
35            'value' => $this->value,
36        ];
37    }
38}