Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
12 / 12
100.00% covered (success)
100.00%
2 / 2
CRAP
100.00% covered (success)
100.00%
1 / 1
Changes
100.00% covered (success)
100.00%
12 / 12
100.00% covered (success)
100.00%
2 / 2
2
100.00% covered (success)
100.00%
1 / 1
 __construct
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 card
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 Cosray\Panel\Dashboard;
6
7use Celema\Quma\Database;
8use Cosray\Contract\DashboardCard;
9use Override;
10
11final readonly class Changes implements DashboardCard
12{
13    public function __construct(
14        private Database $db,
15    ) {}
16
17    #[Override]
18    public function card(): Card
19    {
20        $row = $this->db->dashboard->changes()->one();
21        $recent = (int) ($row['recent'] ?? 0);
22
23        return new Card(
24            label: __('dashboard:changes'),
25            value: (int) ($row['total'] ?? 0),
26            note: __n(
27                'dashboard:recent-changes',
28                'dashboard:recent-changes-plural',
29                $recent,
30            ),
31        );
32    }
33}