Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
5 / 5 |
|
100.00% |
2 / 2 |
CRAP | |
100.00% |
1 / 1 |
| ListTripsHandler | |
100.00% |
5 / 5 |
|
100.00% |
2 / 2 |
2 | |
100.00% |
1 / 1 |
| __construct | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| handle | |
100.00% |
4 / 4 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace App\Trip\Application\Query; |
| 6 | |
| 7 | use App\Shared\Infrastructure\Storage\SignedImageUrl; |
| 8 | use App\Trip\Application\TripAccess; |
| 9 | use App\Trip\Domain\Trip; |
| 10 | use App\Trip\Domain\ValueObject\TripRole; |
| 11 | |
| 12 | final readonly class ListTripsHandler |
| 13 | { |
| 14 | public function __construct( |
| 15 | private TripAccess $access, |
| 16 | private SignedImageUrl $imageUrls, |
| 17 | ) { |
| 18 | } |
| 19 | |
| 20 | /** |
| 21 | * @return list<TripView> |
| 22 | */ |
| 23 | public function handle(ListTripsQuery $query): array |
| 24 | { |
| 25 | return array_map( |
| 26 | /** @param array{Trip, TripRole} $entry */ |
| 27 | fn (array $entry) => TripView::fromTrip($entry[0], $entry[1], $this->imageUrls->for($entry[0]->imageName())), |
| 28 | $this->access->accessibleTrips($query->userId), |
| 29 | ); |
| 30 | } |
| 31 | } |