Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
20 / 20
100.00% covered (success)
100.00%
2 / 2
CRAP
100.00% covered (success)
100.00%
1 / 1
AdminStatsData
100.00% covered (success)
100.00%
20 / 20
100.00% covered (success)
100.00%
2 / 2
2
100.00% covered (success)
100.00%
1 / 1
 __construct
100.00% covered (success)
100.00%
9 / 9
100.00% covered (success)
100.00%
1 / 1
1
 jsonSerialize
100.00% covered (success)
100.00%
11 / 11
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2
3declare(strict_types=1);
4
5namespace App\Domain\Admin\Data;
6
7use App\Support\Row;
8use JsonSerializable;
9
10/**
11 * Platform-wide statistics for admin dashboard.
12 */
13final class AdminStatsData implements JsonSerializable
14{
15    public readonly int $totalInvestors;
16
17    public readonly int $activeInvestors;
18
19    public readonly int $pendingKyc;
20
21    public readonly int $totalAccounts;
22
23    public readonly int $activeAccounts;
24
25    public readonly int $pendingAccounts;
26
27    public readonly string $totalAum;
28
29    public readonly string $totalAvailableForLoan;
30
31    public readonly string $loansOutstanding;
32
33    /**
34     * @param array<mixed> $data
35     */
36    public function __construct(array $data)
37    {
38        $this->totalInvestors = Row::int($data, 'totalInvestors');
39        $this->activeInvestors = Row::int($data, 'activeInvestors');
40        $this->pendingKyc = Row::int($data, 'pendingKyc');
41        $this->totalAccounts = Row::int($data, 'totalAccounts');
42        $this->activeAccounts = Row::int($data, 'activeAccounts');
43        $this->pendingAccounts = Row::int($data, 'pendingAccounts');
44        $this->totalAum = Row::string($data, 'totalAum');
45        $this->totalAvailableForLoan = Row::string($data, 'totalAvailableForLoan');
46        $this->loansOutstanding = Row::string($data, 'loansOutstanding');
47    }
48
49    /**
50     * @return array<string, mixed>
51     */
52    public function jsonSerialize(): array
53    {
54        return [
55            'totalInvestors' => $this->totalInvestors,
56            'activeInvestors' => $this->activeInvestors,
57            'pendingKyc' => $this->pendingKyc,
58            'totalAccounts' => $this->totalAccounts,
59            'activeAccounts' => $this->activeAccounts,
60            'pendingAccounts' => $this->pendingAccounts,
61            'totalAum' => $this->totalAum,
62            'totalAvailableForLoan' => $this->totalAvailableForLoan,
63            'loansOutstanding' => $this->loansOutstanding,
64        ];
65    }
66}