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
UpdateBookHandler
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
 __construct
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 __invoke
100.00% covered (success)
100.00%
10 / 10
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\Application\Query;
11
12use AppDemo\Library\Domain\BookRepository;
13use Phexium\Application\Query\QueryHandlerInterface;
14
15final readonly class UpdateBookHandler implements QueryHandlerInterface
16{
17    public function __construct(
18        private BookRepository $bookRepository
19    ) {}
20
21    public function __invoke(UpdateBookQuery $query): UpdateBookResponse
22    {
23        $book = $this->bookRepository->getById($query->bookId);
24
25        return new UpdateBookResponse(
26            $book->getId()->getValue(),
27            $book->getTitle()->getValue(),
28            $book->getAuthor()->getValue(),
29            $book->getIsbn()->getFormattedValue(),
30            $book->getStatus()->value,
31            $query->formValues,
32            $query->errors
33        );
34    }
35}