<commit_before><?php

namespace Leantony\Html\Tables;

use Leantony\Html\AbstractHtml;

abstract class Table extends AbstractHtml
{
    /**
     * The rows that appear on the table $k => $v
     *
     * @var array
     */
    protected $rows = [];

    /**
     * The name of the variable sent to the loop view
     *
     * @var string
     */
    protected $dataVariableAlias;

    /**
     * The view that holds the loop data
     *
     * @var string
     */
    public $rowsView;

    /**
     * Render buttons on the table
     *
     * @var bool
     */
    protected $renderButtons = true;

    /**
     * @var bool
     */
    protected $paginate = true;

    /**
     * @var bool
     */
    protected $warnIfEmpty = true;

    /**
     * @var mixed
     */
    protected $data;

    /**
     * @return bool
     */
    public function isPaginate()
    {
        return $this->paginate;
    }

    /**
     * @param bool $paginate
     */
    public function setPaginate($paginate)
    {
        $this->paginate = $paginate;
    }

    public function __toString()
    {
        return $this->toHtml();
    }

    /**
     * Get content as a string of HTML.
     *
     * @return string
     */
    public function toHtml()
    {
        return $this->render();
    }

    /**
     * Render the view
     *
     * @return string
     */
    public function render()
    {
        return view('leantony::html.tables.table', $this->compactData())->render();
    }

    /**
     * Specify the data to be sent to the view
     *
     * @param array $params
     * @return array
     */
    protected function compactData($params = [])
    {
        return [
            'rows' => $this->getRows(),
            'renderButtons' => $this->isRenderButtons(),
            'data' => $this->getData(),
            'paginate' => $this->paginate,
            'rowsData' => $this->rowsView ?? $this->getRowsView(),
            'viewButton' => new ViewButton(),
            'deleteButton' => new DeleteButton(),
            'dataVarAlias' => $this->getDataVariableName(),
            'warnIfEmpty' => $this->isWarnIfEmpty()
        ];
    }

    /**
     * Return the rows to be displayed on the table
     *
     * @return array
     */
    abstract public function getRows();

    /**
     * @return bool
     */
    public function isRenderButtons()
    {
        return $this->renderButtons;
    }

    /**
     * @param bool $renderButtons
     */
    public function setRenderButtons($renderButtons)
    {
        $this->renderButtons = $renderButtons;
    }

    /**
     * @return mixed
     */
    public function getData()
    {
        return $this->data;
    }

    /**
     * @param mixed $data
     */
    public function setData($data)
    {
        $this->data = $data;
    }

    /**
     * Return the view that contains data in individual table rows
     *
     * @return string
     */
    abstract public function getRowsView();

    /**
     * @return string
     */
    abstract public function getDataVariableName();

    /**
     * @return bool
     */
    public function isWarnIfEmpty()
    {
        return $this->warnIfEmpty;
    }

    /**
     * @param bool $warnIfEmpty
     */
    public function setWarnIfEmpty($warnIfEmpty)
    {
        $this->warnIfEmpty = $warnIfEmpty;
    }
}<commit_msg>update function docs<commit_after><?php

namespace Leantony\Html\Tables;

use Leantony\Html\AbstractHtml;

abstract class Table extends AbstractHtml
{
    /**
     * The rows that appear on the table $k => $v
     *
     * @var array
     */
    protected $rows = [];

    /**
     * The name of the variable sent to the loop view
     *
     * @var string
     */
    protected $dataVariableAlias;

    /**
     * The view that holds the loop data
     *
     * @var string
     */
    public $rowsView;

    /**
     * Render buttons on the table
     *
     * @var bool
     */
    protected $renderButtons = true;

    /**
     * @var bool
     */
    protected $paginate = true;

    /**
     * @var bool
     */
    protected $warnIfEmpty = true;

    /**
     * @var mixed
     */
    protected $data;

    /**
     * @return bool
     */
    public function isPaginate()
    {
        return $this->paginate;
    }

    /**
     * @param bool $paginate
     */
    public function setPaginate($paginate)
    {
        $this->paginate = $paginate;
    }

    public function __toString()
    {
        return $this->toHtml();
    }

    /**
     * Get content as a string of HTML.
     *
     * @return string
     */
    public function toHtml()
    {
        return $this->render();
    }

    /**
     * Render the view
     *
     * @return string
     */
    public function render()
    {
        return view('leantony::html.tables.table', $this->compactData())->render();
    }

    /**
     * Specify the data to be sent to the view
     *
     * @param array $params
     * @return array
     */
    protected function compactData($params = [])
    {
        return [
            'rows' => $this->getRows(),
            'renderButtons' => $this->isRenderButtons(),
            'data' => $this->getData(),
            'paginate' => $this->paginate,
            'rowsData' => $this->rowsView ?? $this->getRowsView(),
            'viewButton' => new ViewButton(),
            'deleteButton' => new DeleteButton(),
            'dataVarAlias' => $this->getDataVariableName(),
            'warnIfEmpty' => $this->isWarnIfEmpty()
        ];
    }

    /**
     * Return the rows to be displayed on the table
     *
     * @return array
     */
    abstract public function getRows();

    /**
     * @return bool
     */
    public function isRenderButtons()
    {
        return $this->renderButtons;
    }

    /**
     * @param bool $renderButtons
     */
    public function setRenderButtons($renderButtons)
    {
        $this->renderButtons = $renderButtons;
    }

    /**
     * @return mixed
     */
    public function getData()
    {
        return $this->data;
    }

    /**
     * @param mixed $data
     */
    public function setData($data)
    {
        $this->data = $data;
    }

    /**
     * Return the view that contains data in individual table rows
     *
     * @return string
     */
    abstract public function getRowsView();

    /**
     * Specify the data variable sent to the loop view
     * This will be used within the loop view to access the data
     *
     * @return string
     */
    abstract public function getDataVariableName();

    /**
     * @return bool
     */
    public function isWarnIfEmpty()
    {
        return $this->warnIfEmpty;
    }

    /**
     * @param bool $warnIfEmpty
     */
    public function setWarnIfEmpty($warnIfEmpty)
    {
        $this->warnIfEmpty = $warnIfEmpty;
    }
}
{'fraction_non_alphanumeric': 0.12879905576866332, 'fraction_numerical': 0.0, 'mean_word_length': 1.6731072555205047, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 63, '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': '3363799', 'n_tokens_mistral': 2001, 'n_tokens_neox': 1998, 'n_words': 499}