Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
3 / 3
100.00% covered (success)
100.00%
3 / 3
CRAP
100.00% covered (success)
100.00%
1 / 1
AdminSelfAction
100.00% covered (success)
100.00%
3 / 3
100.00% covered (success)
100.00%
3 / 3
3
100.00% covered (success)
100.00%
1 / 1
 cannotRevokeSelf
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 cannotDeleteSelf
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 cannotSuspendSelf
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\Identity\Domain\Exceptions;
6
7use DomainException;
8
9/**
10 * An admin acting on their own account through the admin API in a way that could
11 * lock them out (revoking their own admin, deleting their own account). Blocked so
12 * the admin uses the self-service endpoints (/users/me) for their own account.
13 */
14final class AdminSelfAction extends DomainException
15{
16    public static function cannotRevokeSelf(): self
17    {
18        return new self('You cannot revoke your own admin access.');
19    }
20
21    public static function cannotDeleteSelf(): self
22    {
23        return new self('You cannot delete your own account through the admin API.');
24    }
25
26    public static function cannotSuspendSelf(): self
27    {
28        return new self('You cannot suspend your own account.');
29    }
30}