Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
1 / 1 |
n/a |
0 / 0 |
CRAP | n/a |
0 / 0 |
||
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | /** @license For full copyright and license information, please see the LICENSE.md file. */ |
| 6 | |
| 7 | namespace App\Modules\User\Domain\Repository; |
| 8 | |
| 9 | defined('AMMONLY_APP') || exit('Direct script access is forbidden.'); |
| 10 | |
| 11 | /** |
| 12 | * Contract for managing configurable user impersonation grants in persistent storage. |
| 13 | * |
| 14 | * @package App\Modules\User\Domain\Repository |
| 15 | */ |
| 16 | interface UserImpersonationRepositoryInterface |
| 17 | { |
| 18 | /** |
| 19 | * Checks whether an actor user is explicitly granted impersonation rights for a target user. |
| 20 | * |
| 21 | * @param int $userId Actor user identifier. |
| 22 | * @param int $targetUserId Target user identifier. |
| 23 | * @return bool True if an active grant exists. |
| 24 | */ |
| 25 | public function canImpersonate(int $userId, int $targetUserId): bool; |
| 26 | |
| 27 | /** |
| 28 | * Retrieves all target user IDs that a given actor user is authorized to impersonate. |
| 29 | * |
| 30 | * @param int $userId Actor user identifier. |
| 31 | * @return array<int, int> List of target user IDs. |
| 32 | */ |
| 33 | public function getGrantedTargetUserIds(int $userId): array; |
| 34 | |
| 35 | /** |
| 36 | * Retrieves a full map of all active impersonation grants (actor_id => array of target_ids). |
| 37 | * |
| 38 | * @return array<int, array<int, int>> Map of actor user ID to list of granted target user IDs. |
| 39 | */ |
| 40 | public function getAllGrantsMap(): array; |
| 41 | |
| 42 | /** |
| 43 | * Retrieves all actor user IDs authorized to impersonate a given target user. |
| 44 | * |
| 45 | * @param int $targetUserId Target user identifier. |
| 46 | * @return array<int, int> List of actor user IDs. |
| 47 | */ |
| 48 | public function getGrantedActorUserIds(int $targetUserId): array; |
| 49 | |
| 50 | /** |
| 51 | * Persists or replaces all impersonation grants for a specific actor user. |
| 52 | * |
| 53 | * @param int $userId Actor user identifier. |
| 54 | * @param array<int, int> $targetUserIds List of target user IDs to grant access to. |
| 55 | * @param int $operatorId Identity of administrator performing the change. |
| 56 | */ |
| 57 | public function saveGrants(int $userId, array $targetUserIds, int $operatorId): void; |
| 58 | } |