<commit_before><?php namespace Humweb\Widgets;

use Closure;

/**
 * Class WidgetFactory
 *
 * @package App\Modules\Themes
 */
class WidgetFactory
{
    /**
     * @var array
     */
    protected $widgets = array();

    protected $instantiatedWidgets = [];


    /**
     * @param $name
     * @param $callback
     */
    public function register($name, $callback)
    {
        $this->widgets[$name] = $callback;
    }


    /**
     * Render widget instance
     *
     * @param string $name
     * @param array  $args
     *
     * @return string
     */
    public function render($name, array $args = array())
    {
        if ($this->has($name)) {
            $callback = $this->widgets[$name];

            return $this->executeCallback($callback, $args);
        }

        return '';
    }


    /**
     * Check if widget is registered
     *
     * @param string $name
     *
     * @return bool
     */
    public function has($name)
    {
        return isset($this->widgets[$name]);
    }


    /**
     * Execute callback
     *
     * @param $callback
     * @param $args
     *
     * @return string
     */
    private function executeCallback($callback, $args)
    {
        if (is_string($callback)) {
            return $this->callStringCallback($callback, $args);
        } elseif ($callback instanceof Closure) {
            return call_user_func_array($callback, $args);
        } else {
            return '';
        }
    }


    /**
     * Execute string callback
     *
     * @param string $callback
     * @param array  $args
     *
     * @return string
     */
    function callStringCallback($callback, $args = [])
    {
        if (strpos($callback, '@')) {
            list($klass, $method) = explode('@', $callback);
        } else {
            $klass  = $callback;
            $method = 'render';
        }

        $klass = isset($this->instantiatedWidgets[$klass]) ? $this->instantiatedWidgets[$klass] : new $klass;
<commit_msg>explicitly assign visibility<commit_after><?php namespace Humweb\Widgets;

use Closure;

/**
 * Class WidgetFactory
 *
 * @package App\Modules\Themes
 */
class WidgetFactory
{
    /**
     * @var array
     */
    protected $widgets = array();

    protected $instantiatedWidgets = [];


    /**
     * @param $name
     * @param $callback
     */
    public function register($name, $callback)
    {
        $this->widgets[$name] = $callback;
    }


    /**
     * Render widget instance
     *
     * @param string $name
     * @param array  $args
     *
     * @return string
     */
    public function render($name, array $args = array())
    {
        if ($this->has($name)) {
            $callback = $this->widgets[$name];

            return $this->executeCallback($callback, $args);
        }

        return '';
    }


    /**
     * Check if widget is registered
     *
     * @param string $name
     *
     * @return bool
     */
    public function has($name)
    {
        return isset($this->widgets[$name]);
    }


    /**
     * Execute callback
     *
     * @param $callback
     * @param $args
     *
     * @return string
     */
    protected function executeCallback($callback, $args)
    {
        if (is_string($callback)) {
            return $this->callStringCallback($callback, $args);
        } elseif ($callback instanceof Closure) {
            return call_user_func_array($callback, $args);
        }

        return '';
    }


    /**
     * Execute string callback
     *
     * @param string $callback
     * @param array  $args
     *
     * @return string
     */
    protected function callStringCallback($callback, $args = [])
    {
        if (strpos($callback, '@')) {
            list($klass, $method) = explode('@', $callback);
        } else {
            $klass  = $callback;
            $method = 'render';
        }

        $klass = isset($this->instantiatedWidgets[$klass]) ? $this->instantiatedWidgets[$klass] : new $klass;

{'fraction_non_alphanumeric': 0.14325487218425714, 'fraction_numerical': 0.0, 'mean_word_length': 1.8350071736011477, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 19, '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': '5769431', 'n_tokens_mistral': 1170, 'n_tokens_neox': 1150, 'n_words': 250}