Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
4 / 4 |
|
100.00% |
2 / 2 |
CRAP | |
100.00% |
1 / 1 |
| ArchiveTripHandler | |
100.00% |
4 / 4 |
|
100.00% |
2 / 2 |
2 | |
100.00% |
1 / 1 |
| __construct | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| handle | |
100.00% |
3 / 3 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace App\Trip\Application\Command; |
| 6 | |
| 7 | use App\Trip\Application\TripAccess; |
| 8 | use App\Trip\Domain\TripRepository; |
| 9 | use App\Trip\Domain\ValueObject\TripId; |
| 10 | |
| 11 | final readonly class ArchiveTripHandler |
| 12 | { |
| 13 | public function __construct( |
| 14 | private TripAccess $access, |
| 15 | private TripRepository $trips, |
| 16 | ) { |
| 17 | } |
| 18 | |
| 19 | public function handle(ArchiveTripCommand $command): void |
| 20 | { |
| 21 | // Owner only: stranger → TripNotFound (404), non-owner member → TripAccessDenied (403). |
| 22 | $trip = $this->access->getForManage(new TripId($command->tripId), $command->userId); |
| 23 | |
| 24 | $trip->archive(); |
| 25 | $this->trips->save($trip); |
| 26 | } |
| 27 | } |