Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
13 / 13
100.00% covered (success)
100.00%
1 / 1
CRAP
100.00% covered (success)
100.00%
1 / 1
ListBooksJsonPresenter
100.00% covered (success)
100.00%
13 / 13
100.00% covered (success)
100.00%
1 / 1
1
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
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 Phexium\Presentation\PresenterAbstract;
14use Phexium\Presentation\PresenterInterface;
15
16final class ListBooksJsonPresenter extends PresenterAbstract implements PresenterInterface
17{
18    public function present(ListBooksResponse $response): self
19    {
20        $pagination = $response->pagination;
21
22        $this->viewModel = [
23            'books' => $response->books,
24            'pagination' => [
25                'total_count' => $pagination->totalCount,
26                'page' => $pagination->page,
27                'per_page' => $pagination->perPage,
28                'total_pages' => $pagination->getTotalPages(),
29                'has_next_page' => $pagination->hasNextPage(),
30                'has_previous_page' => $pagination->hasPreviousPage(),
31            ],
32        ];
33
34        return $this;
35    }
36}