1 | <?php |
||
15 | class ImpersonationException extends Exception |
||
16 | { |
||
17 | /* ----------------------------------------------------------------- |
||
18 | | Main Methods |
||
19 | | ----------------------------------------------------------------- |
||
20 | */ |
||
21 | |||
22 | /** |
||
23 | * Make a new exception. |
||
24 | * |
||
25 | * @param string $message |
||
26 | * |
||
27 | * @return static |
||
28 | */ |
||
29 | 12 | public static function make(string $message): self |
|
33 | |||
34 | /** |
||
35 | * Make an exception when the impersonater and impersonated are same person. |
||
36 | * |
||
37 | * @return static |
||
38 | */ |
||
39 | 4 | public static function selfImpersonation(): self |
|
40 | { |
||
41 | 4 | return static::make('The impersonater & impersonated with must be different.'); |
|
42 | } |
||
43 | |||
44 | /** |
||
45 | * Make an exception when the impersonater cannot (or not allowed) impersonate. |
||
46 | * |
||
47 | * @param \Arcanedev\LaravelImpersonator\Contracts\Impersonatable $impersonater |
||
48 | * |
||
49 | * @return static |
||
50 | */ |
||
51 | 4 | public static function cannotImpersonate(Impersonatable $impersonater): self |
|
60 | |||
61 | /** |
||
62 | * Make an exception when the impersonated cannot be impersonated. |
||
63 | * |
||
64 | * @param \Arcanedev\LaravelImpersonator\Contracts\Impersonatable $impersonated |
||
65 | * |
||
66 | * @return static |
||
67 | */ |
||
68 | 4 | public static function cannotBeImpersonated(Impersonatable $impersonated): self |
|
77 | |||
78 | /** |
||
79 | * Make an exception when the impersonator and the impersonated are the same person. |
||
80 | * |
||
81 | * @return static |
||
82 | */ |
||
83 | public static function impersonaterAndImpersonatedAreSame(): self |
||
89 | } |
||
90 |