<?php
/**
 * Here is your custom functions.
 */

if (!function_exists('dd')) {
    /**
     * Dump the passed variables and end the script.
     *
     * @param  mixed  ...$args
     * @return void
     */
    function dd(...$args): void
    {
        if (!in_array(\PHP_SAPI, ['cli', 'phpdbg'], true) && !headers_sent()) {
            header('Content-Type: text/html; charset=utf-8');
        }

        foreach ($args as $arg) {
            \var_dump($arg);
        }

        exit(1);
    }
}

if (!function_exists('dump')) {
    /**
     * Dump the passed variables without ending the script.
     *
     * @param  mixed  ...$args
     * @return void
     */
    function dump(...$args): void
    {
        if (!in_array(\PHP_SAPI, ['cli', 'phpdbg'], true) && !headers_sent()) {
            header('Content-Type: text/html; charset=utf-8');
        }

        foreach ($args as $arg) {
            \var_dump($arg);
        }
    }
}
