<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-2019 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.
 */

namespace Leevel\Option\Helper;

use Leevel\Di\Container;

/**
 * 设置或者获取 option 值
 *
 * @param null|array|string $key
 * @param mixed             $defaults
 *
 * @return mixed
 */
function option($key = null, $defaults = null)
{
    $service = Container::singletons()->make('option');

    if (null === $key) {
        return $service;
    }

    if (is_array($key)) {
        return $service->set($key);
    }

    return $service->get($key, $defaults);
}<commit_msg>efactor(option helper): split option helper fn<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-2019 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.
 */

namespace Leevel\Option\Helper;

use Leevel\Di\Container;
use Leevel\Option\IOption;

/**
 * 配置服务
 *
 * @return \Leevel\Option\IOption
 */
function option(): IOption
{
    return Container::singletons()->make('option');
}

/**
 * 获取 opiton 值
 *
 * @param string     $key
 * @param mixed      $defaults
 * @param null|mixed $default
 *
 * @return mixed
 */
function option_get($key, $default = null)
{
    return option()->get($key, $default);
}

/**
 * 设置 opiton 值
 *
 * @param mixed $name
 * @param mixed $value
 */
function option_set($name, $value = null): void
{
    option()->set($name, $value);
}
{'fraction_non_alphanumeric': 0.17619235317303902, 'fraction_numerical': 0.007094994087504927, 'mean_word_length': 1.9788732394366197, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 11, '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': '2630434', 'n_tokens_mistral': 876, 'n_tokens_neox': 836, 'n_words': 184}