<commit_before><?php
/**
 * Widget Framework
 *
 * @copyright   Copyright (c) 2008-2013 <NAME>
 * @license     http://opensource.org/licenses/mit-license.php MIT License
 */

namespace Widget;

/**
 * A widget to manage widget configurations
 *
 * @author      <NAME> <<EMAIL>>
 */
class Config extends Base
{
    /**
     * Convert configuration data to JSON
     *
     * @param string $name The name of configuration item
     * @return string
     */
    public function toJson($name)
    {
        return json_encode($this->widget->getConfig($name));
    }

    /**
     * Convert configuration data to HTML select options
     *
     * @param string $name The name of configuration item
     * @return string
     */
    public function toOptions($name)
    {
        $html = '';
        foreach ($this->widget->getConfig($name) as $value => $text) {
            if (is_array($text)) {
                $html .= '<optgroup label="' . $value . '">';
                foreach ($text as $v => $t) {
                    $html .= '<option value="' . $v . '">' . $t . '</option>';
                }
                $html .= '</optgroup>';
            } else {
                $html .= '<option value="' . $value . '">' . $text . '</option>';
            }
        }
        return $html;
    }

    /**
     * Adds callback to widget configuration
     *
     * @param string $name
     * @param callable $fn
     * @return $this
     */
    public function add($name, $fn)
    {
        $prevFn = $this->widget->getConfig($name);
        $this->widget->setConfig($name, !$prevFn ? $fn : function() use($fn, $prevFn) {
            $args = func_get_args();
            if (false === call_user_func_array($prevFn, $args)) {
                return false;
            } else {
                return call_user_func_array($fn, $args);
            }
        });
        return $this;
    }
}<commit_msg>removed add method in config widget<commit_after><?php
/**
 * Widget Framework
 *
 * @copyright   Copyright (c) 2008-2013 <NAME>
 * @license     http://opensource.org/licenses/mit-license.php MIT License
 */

namespace Widget;

/**
 * A widget to manage widget configurations
 *
 * @author      <NAME> <<EMAIL>>
 */
class Config extends Base
{
    /**
     * Convert configuration data to JSON
     *
     * @param string $name The name of configuration item
     * @return string
     */
    public function toJson($name)
    {
        return json_encode($this->widget->getConfig($name));
    }

    /**
     * Convert configuration data to HTML select options
     *
     * @param string $name The name of configuration item
     * @return string
     */
    public function toOptions($name)
    {
        $html = '';
        foreach ($this->widget->getConfig($name) as $value => $text) {
            if (is_array($text)) {
                $html .= '<optgroup label="' . $value . '">';
                foreach ($text as $v => $t) {
                    $html .= '<option value="' . $v . '">' . $t . '</option>';
                }
                $html .= '</optgroup>';
            } else {
                $html .= '<option value="' . $value . '">' . $text . '</option>';
            }
        }
        return $html;
    }
}
{'fraction_non_alphanumeric': 0.15456238361266295, 'fraction_numerical': 0.004965859714463066, 'mean_word_length': 1.7267343485617597, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 39, 'https://': 0, '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': '2932780', 'n_tokens_mistral': 939, 'n_tokens_neox': 905, 'n_words': 246}