<commit_before><?php

namespace Rougin\Wildfire\Traits;

/**
 * Paginate Trait
 *
 * @property \CI_Config     $config
 * @property \CI_Input      $input
 * @property \CI_Loader     $load
 * @property \CI_Pagination $pagination
 * @property \CI_URI        $uri
 *
 * @package Wildfire
 * @author  <NAME> <<EMAIL>>
 */
trait PaginateTrait
{
    /**
     * Limits the data based on given configuration and generates pagination links.
     *
     * @param  integer $page
     * @param  integer $total
     * @param  array   $config
     * @return array
     */
    public function paginate($page, $total, $config = array())
    {
        $this->load->library('pagination');

        $pagination = $this->pagination;

        $config = $this->prepare((array) $config);

        $config['per_page'] = (integer) $page;

        $config['total_rows'] = (integer) $total;

        $offset = $this->offset($page, $config);

        $pagination->initialize($config);

        $links = $pagination->create_links();

        return array($offset, $links);
    }

    /**
     * Returns the offset from the defined configuration.
     *
     * @param  integer $page
     * @param  array   $config
     * @return integer
     */
    protected function offset($page, array $config)
    {
        $offset = $this->uri->segment($config['uri_segment']);

        if ($config['page_query_string'] === true) {
            $segment = $config['query_string_segment'];

            $offset = $this->input->get($segment);
        }

        $numbers = $config['use_page_numbers'] && $offset !== 0;

        return $numbers ? ($page * $offset) - $page : $offset;
    }

    /**
     * Retrieves configuration from pagination.php.
     * If not available, will based on given and default data.
     *
     * @param  array $config
     * @return void
     */
    protected function prepare(array $config)<commit_msg>Update PaginateTrait<commit_after><?php

namespace Rougin\Wildfire\Traits;

/**
 * Paginate Trait
 *
 * @property \CI_Config     $config
 * @property \CI_Input      $input
 * @property \CI_Loader     $load
 * @property \CI_Pagination $pagination
 * @property \CI_URI        $uri
 *
 * @package Wildfire
 * @author  <NAME> <<EMAIL>>
 */
trait PaginateTrait
{
    /**
     * Limits the data based on given configuration and generates pagination links.
     *
     * @param  integer $page
     * @param  integer $total
     * @param  array   $config
     * @return array
     */
    public function paginate($page, $total, $config = array())
    {
        $this->load->library('pagination');

        $pagination = $this->pagination;

        $config = $this->prepare((array) $config);

        $config['per_page'] = (integer) $page;

        $config['total_rows'] = (integer) $total;

        $offset = $this->offset($page, $config);

        $pagination->initialize($config);

        $links = $pagination->create_links();

        return array($offset, $links);
    }

    /**
     * Returns the offset from the defined configuration.
     *
     * @param  integer $page
     * @param  array   $config
     * @return integer
     */
    protected function offset($page, array $config)
    {
        $offset = $this->uri->segment($config['uri_segment']);

        if ($config['page_query_string'] === true) {
            $segment = $config['query_string_segment'];

            $offset = $this->input->get($segment);
        }

        $numbers = $config['use_page_numbers'] && $offset !== 0;

        return $numbers ? ($page * $offset) - $page : $offset;
    }

    /**
     * Returns the pagination configuration.
     *
     * @param  array $config
     * @return array
     */
    protected function prepare(array $config)
{'fraction_non_alphanumeric': 0.14539579967689822, 'fraction_numerical': 0.0005385029617662897, 'mean_word_length': 2.383424408014572, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 31, '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': '7530437', 'n_tokens_mistral': 1127, 'n_tokens_neox': 1090, 'n_words': 266}