Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
12 / 12 |
|
100.00% |
2 / 2 |
CRAP | |
100.00% |
1 / 1 |
| Entries | |
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 | use Cosray\Navigation; |
| 10 | |
| 11 | final readonly class Entries implements DashboardCard |
| 12 | { |
| 13 | public function __construct( |
| 14 | private Database $db, |
| 15 | private Navigation $navigation, |
| 16 | ) {} |
| 17 | |
| 18 | public function card(): Card |
| 19 | { |
| 20 | $row = $this->db->dashboard->entries()->one(); |
| 21 | $collections = count($this->navigation->refs()); |
| 22 | |
| 23 | return new Card( |
| 24 | label: __('dashboard:entries'), |
| 25 | value: (int) ($row['total'] ?? 0), |
| 26 | note: __n( |
| 27 | 'dashboard:collection-count', |
| 28 | 'dashboard:collection-count-plural', |
| 29 | $collections, |
| 30 | ), |
| 31 | ); |
| 32 | } |
| 33 | } |