<commit_before><?php

declare(strict_types=1);

/*
 * This file is part of the ************************ package.
 * _____________                           _______________
 *  ______/     \__  _____  ____  ______  / /_  _________
 *   ____/ __   / / / / _ \/ __`\/ / __ \/ __ \/ __ \___
 *    __/ / /  / /_/ /  __/ /  \  / /_/ / / / / /_/ /__
 *      \_\ \_/\____/\___/_/   / / .___/_/ /_/ .___/
 *         \_\                /_/_/         /_/
 *
 * The PHP Framework For Code Poem As Free As Wind. <Query Yet Simple>
 * (c) 2010-2018 http://queryphp.com All rights reserved.
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

use Leevel\Bootstrap\Project;
use Leevel\Debug\Dump;
use Leevel\Di\IContainer;
use Leevel\Log\ILog;

/**
 * 函数库.
 *
 * @author <NAME> <<EMAIL>>
 *
 * @since 2016.11.26
 *
 * @version 1.0
 */
class Leevel
{
    /**
     * call.
     *
     * @param string $method
     * @param array  $args
     *
     * @return mixed
     */
    public static function __callStatic(string $method, array $args)
    {
        return call_user_func_array([static::singletons(), $method], $args);
    }

    /**
     * 获取语言.
     *
     * @param string $text
     * @param array  $arr
     *
     * @return string
     */
    public static function __(string $text, ...$arr)
    {
        static $i18n;

        if (null === $i18n) {
            // @codeCoverageIgnoreStart
            if (!is_object($i18n = static::project('i18n'))) {
                $i18n = 'sprintf';
            // @codeCoverageIgnoreEnd
            } else {
                $i18n = [$i18n, 'gettext'];
            }
        }

        array_unshift($arr, $text);

        return call_user_func_array($i18n, $arr);
    }

    /**
     * 返回项目容器或者注入.
     *
     * @param null|string $instance
     * @param array       $args
     *
     * @return \Leevel\Bootstrap\Project|mixed
     */
    public static function project(?string $instance = null, array $args = [])
    {
        if (null === $instance) {
            return static::singletons();
        }

        return static::singletons()->make($instance, $args);
    }

    /**
     * 返回项目容器或者注入
     * project 别名函数.
     *
     * @param null|string $instance
     * @param array       $args
     *
     * @return \Leevel\Bootstrap\Project|mixed
     */
    public static function app(?string $instance = null, array $args = [])
    {
        return static::project($instance, $args);
    }

    /**
     * 调试变量.
     *
     * @param mixed $var
     * @param array $moreVars
     *
     * @return mixed
     */
    public static function dump($var, ...$moreVars)
    {
        return Dump::dump($var, ...$moreVars);
    }

    /**
     * 调试变量并中断.
     *
     * @param mixed $var
     * @param array $moreVars
     */
    public static function dd($var, ...$moreVars)
    {
        Dump::dumpDie($var, ...$moreVars);
    }

    /**
     * 调试栈信息.
     */
    public static function backtrace()
    {
        Dump::backtrace();
    }

    /**
     * 取得项目的环境变量.支持 boolean, empty 和 null.
     *
     * @param mixed $name
     * @param mixed $defaults
     *
     * @return mixed
     */
    public static function env(string $name, $defaults = null)
    {
        if (false === $value = getenv($name)) {
            $value = static::value($defaults);
        }

        switch ($value) {
            case 'true':
            case '(true)':
                return true;<commit_msg>Ignore debug helper function dd dump db<commit_after><?php

declare(strict_types=1);

/*
 * This file is part of the ************************ package.
 * _____________                           _______________
 *  ______/     \__  _____  ____  ______  / /_  _________
 *   ____/ __   / / / / _ \/ __`\/ / __ \/ __ \/ __ \___
 *    __/ / /  / /_/ /  __/ /  \  / /_/ / / / / /_/ /__
 *      \_\ \_/\____/\___/_/   / / .___/_/ /_/ .___/
 *         \_\                /_/_/         /_/
 *
 * The PHP Framework For Code Poem As Free As Wind. <Query Yet Simple>
 * (c) 2010-2018 http://queryphp.com All rights reserved.
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

use Leevel\Bootstrap\Project;
use Leevel\Debug\Dump;
use Leevel\Di\IContainer;
use Leevel\Log\ILog;

/**
 * 函数库.
 *
 * @author <NAME> <<EMAIL>>
 *
 * @since 2016.11.26
 *
 * @version 1.0
 */
class Leevel
{
    /**
     * call.
     *
     * @param string $method
     * @param array  $args
     *
     * @return mixed
     */
    public static function __callStatic(string $method, array $args)
    {
        return call_user_func_array([static::singletons(), $method], $args);
    }

    /**
     * 获取语言.
     *
     * @param string $text
     * @param array  $arr
     *
     * @return string
     */
    public static function __(string $text, ...$arr)
    {
        static $i18n;

        if (null === $i18n) {
            // @codeCoverageIgnoreStart
            if (!is_object($i18n = static::project('i18n'))) {
                $i18n = 'sprintf';
            // @codeCoverageIgnoreEnd
            } else {
                $i18n = [$i18n, 'gettext'];
            }
        }

        array_unshift($arr, $text);

        return call_user_func_array($i18n, $arr);
    }

    /**
     * 返回项目容器或者注入.
     *
     * @param null|string $instance
     * @param array       $args
     *
     * @return \Leevel\Bootstrap\Project|mixed
     */
    public static function project(?string $instance = null, array $args = [])
    {
        if (null === $instance) {
            return static::singletons();
        }

        return static::singletons()->make($instance, $args);
    }

    /**
     * 返回项目容器或者注入
     * project 别名函数.
     *
     * @param null|string $instance
     * @param array       $args
     *
     * @return \Leevel\Bootstrap\Project|mixed
     */
    public static function app(?string $instance = null, array $args = [])
    {
        return static::project($instance, $args);
    }

    /**
     * 调试变量.
     *
     * @param mixed $var
     * @param array $moreVars
     *
     * @return mixed
     * @codeCoverageIgnore
     */
    public static function dump($var, ...$moreVars)
    {
        return Dump::dump($var, ...$moreVars);
    }

    /**
     * 调试变量并中断.
     *
     * @param mixed $var
     * @param array $moreVars
     * @codeCoverageIgnore
     */
    public static function dd($var, ...$moreVars)
    {
        Dump::dumpDie($var, ...$moreVars);
    }

    /**
     * 调试栈信息.
     *
     * @codeCoverageIgnore
     */
    public static function backtrace()
    {
        Dump::backtrace();
    }

    /**
     * 取得项目的环境变量.支持 boolean, empty 和 null.
     *
     * @param mixed $name
     * @param mixed $defaults
     *
     * @return mixed
     */
    public static function env(string $name, $defaults = null)
    {
        if (false === $value = getenv($name)) {
            $value = static::value($defaults);
        }

        switch ($value) {
            case 'true':
            case '(true)':
                return true;
{'fraction_non_alphanumeric': 0.15305547733032948, 'fraction_numerical': 0.009856378484933821, 'mean_word_length': 1.5942293644996348, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 2, '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': '3610120', 'n_tokens_mistral': 2448, 'n_tokens_neox': 2384, 'n_words': 486}