<commit_before><?php
/**
 * This file is part of the Ray.AuraSqlModule package
 *
 * @license http://opensource.org/licenses/MIT MIT
 */
namespace Ray\AuraSqlModule\PagerFanta;

use Aura\Sql\ExtendedPdo;
use Aura\Sql\ExtendedPdoInterface;
use Pagerfanta\Adapter\AdapterInterface;

class ExtendedPdoAdapter implements AdapterInterface
{
    /**
     * @var ExtendedPdo
     */
    private $pdo;

    /**
     * @var string
     */
    private $sql;

    /**
     * @var
     */
    private $params;

    /**
     * @param ExtendedPdoInterface $pdo
     * @param string               $sql
     * @param array                $params
     */
    public function __construct(ExtendedPdoInterface $pdo, $sql, array $params)
    {
        $this->pdo = $pdo;
        $this->sql = $sql;
        $this->params = $params;
    }

    /**
     * {@inheritdoc}
     */
    public function getNbResults()
    {
        // be smart and try to guess the total number of records
        $countQuery = $this->rewriteCountQuery($this->sql);
        if (! $countQuery) {
            // GROUP BY => fetch the whole result set and count the rows returned
            $result = $this->pdo->query($this->sql)->fetchAll();
            $count = count($result);

            return (int) $count;
        }
        if ($this->params) {
            $sth = $this->pdo->prepareWithValues($this->sql, $this->params);
            $sth->execute();
            $count = $sth->fetchAll();

            return (int) count($count);
        }
        $count = $this->pdo->query($countQuery)->fetchColumn();
<commit_msg>add type<commit_after><?php
/**
 * This file is part of the Ray.AuraSqlModule package
 *
 * @license http://opensource.org/licenses/MIT MIT
 */
namespace Ray\AuraSqlModule\PagerFanta;

use Aura\Sql\ExtendedPdo;
use Aura\Sql\ExtendedPdoInterface;
use Pagerfanta\Adapter\AdapterInterface;

class ExtendedPdoAdapter implements AdapterInterface
{
    /**
     * @var ExtendedPdo
     */
    private $pdo;

    /**
     * @var string
     */
    private $sql;

    /**
     * @var
     */
    private $params;

    public function __construct(ExtendedPdoInterface $pdo, string $sql, array $params)
    {
        $this->pdo = $pdo;
        $this->sql = $sql;
        $this->params = $params;
    }

    /**
     * {@inheritdoc}
     */
    public function getNbResults()
    {
        // be smart and try to guess the total number of records
        $countQuery = $this->rewriteCountQuery($this->sql);
        if (! $countQuery) {
            // GROUP BY => fetch the whole result set and count the rows returned
            $result = $this->pdo->query($this->sql)->fetchAll();
            $count = count($result);

            return (int) $count;
        }
        if ($this->params) {
            $sth = $this->pdo->prepareWithValues($this->sql, $this->params);
            $sth->execute();
            $count = $sth->fetchAll();

            return (int) count($count);
        }
        $count = $this->pdo->query($countQuery)->fetchColumn();

{'fraction_non_alphanumeric': 0.14299900695134063, 'fraction_numerical': 0.0, 'mean_word_length': 2.0463709677419355, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 43, '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': '7304539', 'n_tokens_mistral': 935, 'n_tokens_neox': 908, 'n_words': 209}