Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
7 / 7
100.00% covered (success)
100.00%
1 / 1
CRAP
100.00% covered (success)
100.00%
1 / 1
ListBooksJsonPresenter
100.00% covered (success)
100.00%
7 / 7
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
1 / 1
 present
100.00% covered (success)
100.00%
7 / 7
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\ListBooksResponse;
13use Override;
14use Phexium\Application\ResponseInterface;
15use Phexium\Domain\TypeGuard;
16use Phexium\Presentation\PresenterAbstract;
17use Phexium\Presentation\PresenterInterface;
18
19final class ListBooksJsonPresenter extends PresenterAbstract implements PresenterInterface
20{
21    #[Override]
22    public function present(ResponseInterface $response): self
23    {
24        TypeGuard::that($response)->isInstanceOf(ListBooksResponse::class);
25
26        $books = $response->books;
27
28        $this->viewModel = [
29            'books' => $books,
30            'count' => count($books),
31        ];
32
33        return $this;
34    }
35}