<?php

namespace Formatrica\Registration;

if ( ! defined( 'ABSPATH' ) ) {
	exit;
}

final class Login_Messages
{
    /**
     * Add messages on the login screen based on verification status query arg.
     *
     * @param string $message
     * @return string
     */
    public function add_login_message(string $message): string
    {
        $status = isset($_GET['fmt_verify_status']) ? sanitize_key(wp_unslash($_GET['fmt_verify_status'])) : ''; // phpcs:ignore WordPress.Security.NonceVerification.Recommended
        if ($status === '') {
            return $message;
        }

        switch ($status) {
            case 'success':
                $extra = '<div class="message notice notice-success"><p>' . esc_html__('Your email has been confirmed. You can now log in.', 'formatrica') . '</p></div>';
                break;
            case 'expired':
                $extra = '<div class="message notice notice-error"><p>' . esc_html__('Verification link is invalid or expired. Please register again or request a new link.', 'formatrica') . '</p></div>';
                break;
            default:
                $extra = '<div class="message notice notice-error"><p>' . esc_html__('Invalid verification request.', 'formatrica') . '</p></div>';
                break;
        }

        return $extra . $message;
    }
}
