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