Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
15 / 15 |
|
100.00% |
2 / 2 |
CRAP | |
100.00% |
1 / 1 |
| UpdateBookHtmlPresenter | |
100.00% |
15 / 15 |
|
100.00% |
2 / 2 |
2 | |
100.00% |
1 / 1 |
| present | |
100.00% |
14 / 14 |
|
100.00% |
1 / 1 |
1 | |||
| getViewModel | |
100.00% |
1 / 1 |
|
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\UpdateBookQueryResponse; |
| 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 UpdateBookHtmlPresenter extends PresenterAbstract implements PresenterInterface |
| 20 | { |
| 21 | #[Override] |
| 22 | public function present(ResponseInterface $response): self |
| 23 | { |
| 24 | TypeGuard::that($response)->isInstanceOf(UpdateBookQueryResponse::class); |
| 25 | |
| 26 | $book = (object) [ |
| 27 | 'id' => $response->bookId, |
| 28 | 'title' => $response->bookTitle, |
| 29 | 'author' => $response->bookAuthor, |
| 30 | 'isbn' => $response->bookIsbn, |
| 31 | 'status' => $response->bookStatus, |
| 32 | ]; |
| 33 | |
| 34 | $this->viewModel = new UpdateBookHtmlViewModel( |
| 35 | book: $book, |
| 36 | formValues: $response->formValues, |
| 37 | errors: $response->errors |
| 38 | ); |
| 39 | |
| 40 | return $this; |
| 41 | } |
| 42 | |
| 43 | #[Override] |
| 44 | public function getViewModel(): UpdateBookHtmlViewModel |
| 45 | { |
| 46 | return $this->viewModel; |
| 47 | } |
| 48 | } |