*/ private static array $scopes = []; /** * @param array $user * @param list $scopes */ public static function set(array $user, array $scopes): void { self::$user = $user; self::$scopes = $scopes; } /** * @return array */ public static function user(): array { if (self::$user === null) { // Unreachable if the middleware stack is intact; fail closed. throw new \LogicException('MCP identity requested before IdentityMiddleware ran'); } return self::$user; } /** tickets:write implies tickets:read (scope hierarchy, MCP spec §Scope Challenge Handling). */ public static function canRead(array $scopes): bool { return in_array(self::SCOPE_READ, $scopes, true) || in_array(self::SCOPE_WRITE, $scopes, true); } public static function canWrite(array $scopes): bool { return in_array(self::SCOPE_WRITE, $scopes, true); } }