<commit_before><?php

namespace Phile\Plugin\Siezi\PhileIndexPaginate;

class PagePaginator {

    protected $settings = [];

    protected $renderer;

    public function __construct($settings) {
        $this->settings = $settings;
    }

    public function render($pages) {
        $paginator = $this->getPaginator($pages);
        if (!$paginator) {
            return false;
        }
        $out = [];
        foreach ($paginator['items'] as $page) {
            $out[] = $this->renderTemplate(
              'content',
              [
                'current_page' => $page,
                'meta' => $page->getMeta(),
                'content' => $page->getContent(),
              ]);
        }

        $divider = $this->settings['templates']['divider'];
        $out = implode($divider, $out);

        $out .= $this->buildNavigation($paginator);
        return $out;
    }

    protected function getPaginator($items) {
        $current = 0;
        $itemsPerPage = $this->settings['itemsPerPage'];

        $input = filter_input(INPUT_GET, 'page', FILTER_VALIDATE_INT);
		if ($input) {
			$input--; // norm to base 0 index
			$first = $itemsPerPage * $input;
			if (isset($items[$first])) {
				$current = $input;
			} else {<commit_msg>fix paginator<commit_after><?php

namespace Phile\Plugin\Siezi\PhileIndexPaginate;

class PagePaginator {

    protected $settings = [];

    protected $renderer;

    public function __construct($settings) {
        $this->settings = $settings;
    }

    public function render($pages) {
        $paginator = $this->getPaginator($pages);
        if (!$paginator) {
            return false;
        }
        $out = [];
        foreach ($paginator['items'] as $page) {
            $out[] = $this->renderTemplate(
              'content',
              [
                'current_page' => $page,
                'meta' => $page->getMeta(),
                'content' => $page->getContent(),
              ]);
        }

        $divider = $this->settings['templates']['divider'];
        $out = implode($divider, $out);

        $out .= $this->buildNavigation($paginator);
        return $out;
    }

    protected function getPaginator($items) {
        $current = 0;
        $itemsPerPage = $this->settings['itemsPerPage'];

        $input = filter_input(INPUT_GET, 'page', FILTER_VALIDATE_INT);
		if ($input) {
			$input--; // norm to base 0 index
			$first = $itemsPerPage * $input;
			if (count($items) - 1 >= $first) {
				$current = $input;
			} else {
{'fraction_non_alphanumeric': 0.15644904458598727, 'fraction_numerical': 0.0019904458598726115, 'mean_word_length': 2.0683760683760686, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 26, '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': '7453977', 'n_tokens_mistral': 774, 'n_tokens_neox': 734, 'n_words': 149}