user_login ) ? (string) $user->user_login : ''; } /** * Log-safe token representation. First 4 chars + ellipsis + last 2 * chars, or '(empty)' when input is empty. * * Use this ONLY for log lines / debug strings. NEVER use it as the * actual snippet payload (FR-002 security note). * * @param string $token Raw Application Password (may be empty). * * @return string Log-safe redacted representation. */ protected function redact_token( string $token ): string { if ( '' === $token ) { return '(empty)'; } // PHP multibyte-safe substr — Application Passwords are ASCII but // belt-and-suspenders for arbitrary token strings. $prefix = mb_substr( $token, 0, 4 ); $suffix = mb_substr( $token, -2 ); return $prefix . '…' . $suffix; } }