Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
2 / 2
CRAP
100.00% covered (success)
100.00%
1 / 1
TripAccessDenied
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
2 / 2
2
100.00% covered (success)
100.00%
1 / 1
 cannotWriteExpense
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 cannotManageTrip
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2
3declare(strict_types=1);
4
5namespace App\Trip\Domain\Exceptions;
6
7use DomainException;
8
9/**
10 * The caller can see the trip but lacks the capability for this action (e.g. a
11 * viewer trying to write an expense, or a non-owner trying to edit the trip).
12 * Maps to 403 — unlike a stranger, who gets 404 (no existence leak).
13 */
14final class TripAccessDenied extends DomainException
15{
16    public static function cannotWriteExpense(): self
17    {
18        return new self('You do not have permission to modify expenses on this trip.');
19    }
20
21    public static function cannotManageTrip(): self
22    {
23        return new self('Only the trip owner can perform this action.');
24    }
25}