Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
7 / 7 |
|
100.00% |
1 / 1 |
CRAP | |
100.00% |
1 / 1 |
| LoanStatusBadgeService | |
100.00% |
7 / 7 |
|
100.00% |
1 / 1 |
6 | |
100.00% |
1 / 1 |
| __invoke | |
100.00% |
7 / 7 |
|
100.00% |
1 / 1 |
6 | |||
| 1 | <?php |
| 2 | |
| 3 | // ╔════════════════════════════════════════════════════════════╗ |
| 4 | // ║ MIT Licence (#Expat) - https://opensource.org/licenses/MIT ║ |
| 5 | // ║ Copyright 2026 Frederic Poeydomenge <dyno@phexium.com> ║ |
| 6 | // ╚════════════════════════════════════════════════════════════╝ |
| 7 | |
| 8 | declare(strict_types=1); |
| 9 | |
| 10 | namespace AppDemo\Loan\Presentation\Service; |
| 11 | |
| 12 | final readonly class LoanStatusBadgeService |
| 13 | { |
| 14 | public function __invoke(string $status, bool $isOverdue = false): string |
| 15 | { |
| 16 | if ($status === 'active' && $isOverdue) { |
| 17 | return 'bg-danger'; |
| 18 | } |
| 19 | |
| 20 | return match ($status) { |
| 21 | 'active' => 'bg-warning text-dark', |
| 22 | 'returned' => 'bg-success', |
| 23 | default => 'bg-secondary', |
| 24 | }; |
| 25 | } |
| 26 | } |