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