<commit_before><?php
/**
 * Response
 *
 * @package     Oni
 * @author      <NAME>
 * @copyright   Copyright (c) <NAME> (https://scar.tw)
 * @link        https://github.com/scarwu/Oni
 */

namespace Oni\Web\Http;

class Res
{
    /**
     * @var object
     */
    private static $_instance = null;

    /**
     * Initialize
     */
    public static function init()
    {
        if (null === self::$_instance) {
            self::$_instance = new self;
        }

        return self::$_instance;
    }

    /**
     * Construct
     *
     * This function is private, so this class is singleton pattern
     */
    private function __construct() {}

    /**
     * Redirect
     *
     * @param string $path
     */
    public function redirect($path)
    {
        if (true === is_string($path)) {
            header("Location: {$path}");
        }
    }

    /**
     * Render HTML
     *
     * @param string $data
     */
    public function html($data)
    {
        header('Content-Type: text/html');

        if (true === is_string($data)) {
            echo $data;
        }
    }

    /**
     * Render JSON
     *
     * @param array $data
     * @param integer $option
     */
    public function json($data, $option = null)
    {
        header('Content-Type: application/json');

        echo json_encode($data, $option);
    }
}<commit_msg>1. updat http res<commit_after><?php
/**
 * Response
 *
 * @package     Oni
 * @author      <NAME>
 * @copyright   Copyright (c) <NAME> (https://scar.tw)
 * @link        https://github.com/scarwu/Oni
 */

namespace Oni\Web\Http;

class Res
{
    /**
     * @var object
     */
    private static $_instance = null;

    /**
     * Initialize
     */
    public static function init()
    {
        if (null === self::$_instance) {
            self::$_instance = new self;
        }

        return self::$_instance;
    }

    /**
     * Construct
     *
     * This function is private, so this class is singleton pattern
     */
    private function __construct() {}

    /**
     * Redirect
     *
     * @param string $path
     */
    public function redirect($path)
    {
        if (true === is_string($path)) {
            header("Location: {$path}");
        }
    }

    /**
     * Render HTML
     *
     * @param string $data
     */
    public function html($data)
    {
        header('Content-Type: text/html');

        if (true === is_string($data)) {
            echo $data;
        }
    }

    /**
     * Render JSON
     *
     * @param array $data
     * @param integer $option
     */
    public function json($data, $option = null)
    {
        header('Content-Type: application/json');

        echo true === isset($option)
            ? json_encode($data, $option)
            : json_encode($data);
    }
}
{'fraction_non_alphanumeric': 0.146900752418488, 'fraction_numerical': 0.00035829451809387314, 'mean_word_length': 1.6166822867853796, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 7, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6404368', 'n_tokens_mistral': 850, 'n_tokens_neox': 835, 'n_words': 196}