<commit_before><?php
namespace Riesenia\Utility\Kendo;

/**
 * Base class for Kendo helpers
 *
 * @author <NAME> <<EMAIL>>
 */
abstract class KendoHelper
{
    /**
     * Id of the main element
     *
     * @var string
     */
    protected $_id;

    /**
     * Kendo Model
     *
     * @var Riesenia\Kendo\Widget\Model
     */
    public $model = null;

    /**
     * Kendo data source
     *
     * @var Riesenia\Kendo\Widget\DataSource
     */
    public $dataSource = null;

    /**
     * Kendo widget
     *
     * @var Riesenia\Kendo\Widget\Base
     */
    protected $_widget = null;

    /**
     * HTML attributes
     *
     * @var array
     */
    protected $_htmlAttributes = [];

    /**
     * Class aliases
     *
     * @var array
     */
    protected static $_aliases = [];

    /**
     * Construct the helper
     *
     * @param string id
     */
    public function __construct($id)
    {
        $this->_id = $id;
    }

    /**
     * Return new instance
     *
     * @param string id
     * @return Riesenia\Utility\Kendo\KendoHelper
     */
    public static function create($id)
    {
        return new static($id);
    }

    /**
     * Define class alias
     *
     * @param string alias
     * @param string full class name
     * @return void
     */
    public static function alias($alias, $class)
    {
        static::$_aliases[$alias] = $class;
    }

    /**
     * Return rendered HTML
     *
     * @return string
     */
    abstract public function html();

    /**
     * Return rendered javascript
     *
     * @return string
     */
    abstract public function script();

    /**
     * Add transport (passed to datasource)
     *
     * @param string type
     * @param array options
     * @return Riesenia\Utility\Kendo\KendoHelper
     */
    public function addTransport($type, $options = [])
    {
        $this->dataSource->addTransport($type, $options);

        return $this;
    }

    /**
     * Add field (passed to model)
     *
     * @param string field name
     * @param array options
     * @return Riesenia\Utility\Kendo\KendoHelper
     */
    public function addField($key, $options = [])
    {
        $this->model->addField($key, $options);

        return $this;
    }

    /**
     * Add HTML attribute
     *
     * @param string name
     * @param string value
     * @return Riesenia\Utility\Kendo\KendoHelper
     */
    public function addAttribute($name, $value)
    {
        $this->_htmlAttributes[$name] = $value;

        return $this;
    }

    /**
     * Output HTML on echoing
     *
     * @return string
     */
    public function __toString()
    {
        return $this->html();
    }

    /**
     * Render input
     *
     * @param string id attribute
     * @return string
     */
    protected function _input($id)
    {
        return $this->_tag('input', false, array_merge($this->_htmlAttributes, ['id' => $id]));
    }

    /**
     * Render HTML tag
     *
     * @param string tag name
     * @param string|bool content (false for not pair tag)
     * @param array attributes
     * @return string
     */
    protected function _tag($name, $content = false, $attributes = [])
    {
        $tag = '<' . $name;

        foreach ($attributes as $attribute => $value) {
            $tag .= ' ' . $attribute . '="' . $value . '"';
        }

        $tag .= $content === false ? ' />' : '>' . $content . '</' . $name . '>';

        return $tag;
    }

    /**
     * Handle dynamic method calls - forward them to the widget
     *
     * @param string method name
     * @param array arguments
     * @return mixed
     */
    public function __call($method, $arguments)
    {
        if (is_null($this->_widget)) {
            throw new \BadMethodCallException("Unknown method: " . $method);<commit_msg>handle bool & null attributes<commit_after><?php
namespace Riesenia\Utility\Kendo;

/**
 * Base class for Kendo helpers
 *
 * @author <NAME> <<EMAIL>>
 */
abstract class KendoHelper
{
    /**
     * Id of the main element
     *
     * @var string
     */
    protected $_id;

    /**
     * Kendo Model
     *
     * @var Riesenia\Kendo\Widget\Model
     */
    public $model = null;

    /**
     * Kendo data source
     *
     * @var Riesenia\Kendo\Widget\DataSource
     */
    public $dataSource = null;

    /**
     * Kendo widget
     *
     * @var Riesenia\Kendo\Widget\Base
     */
    protected $_widget = null;

    /**
     * HTML attributes
     *
     * @var array
     */
    protected $_htmlAttributes = [];

    /**
     * Class aliases
     *
     * @var array
     */
    protected static $_aliases = [];

    /**
     * Construct the helper
     *
     * @param string id
     */
    public function __construct($id)
    {
        $this->_id = $id;
    }

    /**
     * Return new instance
     *
     * @param string id
     * @return Riesenia\Utility\Kendo\KendoHelper
     */
    public static function create($id)
    {
        return new static($id);
    }

    /**
     * Define class alias
     *
     * @param string alias
     * @param string full class name
     * @return void
     */
    public static function alias($alias, $class)
    {
        static::$_aliases[$alias] = $class;
    }

    /**
     * Return rendered HTML
     *
     * @return string
     */
    abstract public function html();

    /**
     * Return rendered javascript
     *
     * @return string
     */
    abstract public function script();

    /**
     * Add transport (passed to datasource)
     *
     * @param string type
     * @param array options
     * @return Riesenia\Utility\Kendo\KendoHelper
     */
    public function addTransport($type, $options = [])
    {
        $this->dataSource->addTransport($type, $options);

        return $this;
    }

    /**
     * Add field (passed to model)
     *
     * @param string field name
     * @param array options
     * @return Riesenia\Utility\Kendo\KendoHelper
     */
    public function addField($key, $options = [])
    {
        $this->model->addField($key, $options);

        return $this;
    }

    /**
     * Add HTML attribute
     *
     * @param string name
     * @param mixed value
     * @return Riesenia\Utility\Kendo\KendoHelper
     */
    public function addAttribute($name, $value)
    {
        $this->_htmlAttributes[$name] = $value;

        return $this;
    }

    /**
     * Output HTML on echoing
     *
     * @return string
     */
    public function __toString()
    {
        return $this->html();
    }

    /**
     * Render input
     *
     * @param string id attribute
     * @return string
     */
    protected function _input($id)
    {
        return $this->_tag('input', false, array_merge($this->_htmlAttributes, ['id' => $id]));
    }

    /**
     * Render HTML tag
     *
     * @param string tag name
     * @param string|bool content (false for not pair tag)
     * @param array attributes
     * @return string
     */
    protected function _tag($name, $content = false, $attributes = [])
    {
        $tag = '<' . $name;

        foreach ($attributes as $attribute => $value) {
            if (!is_null($value) && $value !== false) {
                $tag .= ' ' . $attribute . '="' . ($value === true ? $attribute : $value) . '"';
            }
        }

        $tag .= $content === false ? ' />' : '>' . $content . '</' . $name . '>';

        return $tag;
    }

    /**
     * Handle dynamic method calls - forward them to the widget
     *
     * @param string method name
     * @param array arguments
     * @return mixed
     */
    public function __call($method, $arguments)
    {
        if (is_null($this->_widget)) {
            throw new \BadMethodCallException("Unknown method: " . $method);
{'fraction_non_alphanumeric': 0.13584710743801653, 'fraction_numerical': 0.0, 'mean_word_length': 1.7338510412989763, 'pattern_counts': {'":': 0, '<': 15, '<?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': '7026566', 'n_tokens_mistral': 2353, 'n_tokens_neox': 2293, 'n_words': 577}