Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
5 / 5 |
|
100.00% |
2 / 2 |
CRAP | |
100.00% |
1 / 1 |
| GetTripHandler | |
100.00% |
5 / 5 |
|
100.00% |
2 / 2 |
4 | |
100.00% |
1 / 1 |
| __construct | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| handle | |
100.00% |
4 / 4 |
|
100.00% |
1 / 1 |
3 | |||
| 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\ValueObject\TripId; |
| 10 | |
| 11 | final readonly class GetTripHandler |
| 12 | { |
| 13 | public function __construct( |
| 14 | private TripAccess $access, |
| 15 | private SignedImageUrl $imageUrls, |
| 16 | ) { |
| 17 | } |
| 18 | |
| 19 | public function handle(GetTripQuery $query): ?TripView |
| 20 | { |
| 21 | [$trip, $role] = $this->access->readableWithRole(new TripId($query->tripId), $query->userId); |
| 22 | |
| 23 | return $trip === null || $role === null |
| 24 | ? null |
| 25 | : TripView::fromTrip($trip, $role, $this->imageUrls->for($trip->imageName())); |
| 26 | } |
| 27 | } |