Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
12 / 12 |
|
100.00% |
1 / 1 |
CRAP | |
100.00% |
1 / 1 |
| DetailBookJsonPresenter | |
100.00% |
12 / 12 |
|
100.00% |
1 / 1 |
1 | |
100.00% |
1 / 1 |
| present | |
100.00% |
12 / 12 |
|
100.00% |
1 / 1 |
1 | |||
| 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\Library\Presentation; |
| 11 | |
| 12 | use AppDemo\Library\Application\Query\DetailBookResponse; |
| 13 | use Override; |
| 14 | use Phexium\Application\ResponseInterface; |
| 15 | use Phexium\Domain\TypeGuard; |
| 16 | use Phexium\Presentation\PresenterAbstract; |
| 17 | use Phexium\Presentation\PresenterInterface; |
| 18 | |
| 19 | final class DetailBookJsonPresenter extends PresenterAbstract implements PresenterInterface |
| 20 | { |
| 21 | #[Override] |
| 22 | public function present(ResponseInterface $response): self |
| 23 | { |
| 24 | TypeGuard::that($response)->isInstanceOf(DetailBookResponse::class); |
| 25 | |
| 26 | $data = [ |
| 27 | 'id' => $response->id, |
| 28 | 'title' => $response->title, |
| 29 | 'author' => $response->author, |
| 30 | 'isbn' => $response->isbn, |
| 31 | 'status' => $response->status, |
| 32 | ]; |
| 33 | |
| 34 | $this->viewModel = [ |
| 35 | 'book' => $data, |
| 36 | ]; |
| 37 | |
| 38 | return $this; |
| 39 | } |
| 40 | } |