Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
10 / 10
100.00% covered (success)
100.00%
2 / 2
CRAP
100.00% covered (success)
100.00%
1 / 1
DetailBookHtmlPresenter
100.00% covered (success)
100.00%
10 / 10
100.00% covered (success)
100.00%
2 / 2
2
100.00% covered (success)
100.00%
1 / 1
 present
100.00% covered (success)
100.00%
9 / 9
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\DetailBookResponse;
13use Override;
14use Phexium\Presentation\PresenterAbstract;
15use Phexium\Presentation\PresenterInterface;
16
17final class DetailBookHtmlPresenter extends PresenterAbstract implements PresenterInterface
18{
19    public function present(DetailBookResponse $response): self
20    {
21        $this->viewModel = new DetailBookHtmlViewModel(
22            id: $response->id,
23            title: $response->title,
24            author: $response->author,
25            isbn: $response->isbn,
26            status: $response->status,
27            can_update_book: $this->context?->userCan('book.update') ?? false
28        );
29
30        return $this;
31    }
32
33    #[Override]
34    public function getViewModel(): DetailBookHtmlViewModel
35    {
36        return $this->viewModel;
37    }
38}