Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
8 / 8 |
|
100.00% |
2 / 2 |
CRAP | |
100.00% |
1 / 1 |
| HomeUseCase | |
100.00% |
8 / 8 |
|
100.00% |
2 / 2 |
3 | |
100.00% |
1 / 1 |
| __construct | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| execute | |
100.00% |
7 / 7 |
|
100.00% |
1 / 1 |
2 | |||
| 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\Homepage\Application\UseCase; |
| 11 | |
| 12 | use Override; |
| 13 | use Phexium\Application\UseCase\UseCaseInterface; |
| 14 | use Phexium\Application\UseCase\UseCaseRequestInterface; |
| 15 | use Phexium\Application\UseCase\UseCaseResponseInterface; |
| 16 | use Phexium\Domain\TypeGuard; |
| 17 | use Phexium\Plugin\Clock\Port\ClockInterface; |
| 18 | |
| 19 | final readonly class HomeUseCase implements UseCaseInterface |
| 20 | { |
| 21 | public function __construct( |
| 22 | private ClockInterface $clock |
| 23 | ) {} |
| 24 | |
| 25 | #[Override] |
| 26 | public function execute(UseCaseRequestInterface $request): UseCaseResponseInterface |
| 27 | { |
| 28 | TypeGuard::that($request)->isInstanceOf(HomeRequest::class); |
| 29 | |
| 30 | $greeting = $request->userEmail |
| 31 | ? sprintf('Welcome, %s', $request->userEmail) |
| 32 | : 'Welcome to CleanShelf'; |
| 33 | |
| 34 | $messageOfTheDay = 'Reading is a window to a magical world.'; |
| 35 | |
| 36 | $currentDateTime = $this->clock->now(); |
| 37 | |
| 38 | return new HomeResponse($greeting, $messageOfTheDay, $currentDateTime); |
| 39 | } |
| 40 | } |