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