<?php function response_json(Array $resp = []) { @header('Content-Type: application/json'); return json_encode($resp); } function app() { global $app; return $app; }; function dd($var) { die(var_dump($var)); } function gen_token(int $user_id) :String { return hash_hmac('sha256', bin2hex(random_bytes(16)), $user_id); } function sanitize_input(String $var) :String { return htmlspecialchars(strip_tags(trim($var)), ENT_QUOTES, 'UTF-8'); } function get_create_at_timestamp() :String { return date("Y-m-d H:i:s"); } function error_response(String $class, String $errtext) :Array { return response(false, [ "error" => [ "class" => ucfirst($class), "text" => $errtext ] ]); } function success_response(Array $data = []) :Array { return response(true, [ "data" => $data ]); } function response(bool $status = true, Array $body = []) :Array { return [ "status" => $status, "response" => $body ]; }