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