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