<?php

namespace App\Core;

/**
 * ITSWEBER CMS – Response Helper
 */
class Response
{
    /**
     * Send HTML response.
     */
    public static function html(string $content, int $statusCode = 200): void
    {
        http_response_code($statusCode);
        header('Content-Type: text/html; charset=utf-8');
        echo $content;
    }

    /**
     * Send JSON response.
     */
    public static function json(array $data, int $statusCode = 200): void
    {
        http_response_code($statusCode);
        header('Content-Type: application/json; charset=utf-8');
        echo json_encode($data, JSON_UNESCAPED_UNICODE);
    }

    /**
     * Redirect to a URL.
     */
    public static function redirect(string $url, int $statusCode = 302): void
    {
        http_response_code($statusCode);
        header('Location: ' . $url);
        exit;
    }

    /**
     * Send a 404 response.
     */
    public static function notFound(string $message = 'Page Not Found'): void
    {
        http_response_code(404);
        echo $message;
    }

    /**
     * Send a 403 response.
     */
    public static function forbidden(string $message = 'Forbidden'): void
    {
        http_response_code(403);
        echo $message;
    }
}
