<commit_before><?php
/**
 * This file is a part of the NDBF library
 *
 * @copyright (c) <NAME> (http://www.slamecka.cz)
 *
 * License can be found within the file license.txt in the root folder.
 *
 */

namespace NDBF;

class Repository extends \Nette\Object
{
    /* ---------------------------- VARIABLES ------------------------------- */

    /** @var \NDBF\RepositoryManager */
    protected $parent;

    /** @var \Nette\Database\Connection */
    protected $connection;

    /** @var string Associated table name */
    protected $table_name;


    /* ------------------------ CONSTRUCTOR, DESIGN ------------------------- */

    public function __construct(RepositoryManager $parent, \Nette\Database\Connection $connection, $table_name = null)
    {
        $this->parent = $parent;
        $this->connection = $connection;

        // DATABASE TABLE NAME
        if ($table_name === null) {
            $table_name = get_class($this);
            $table_name = substr($table_name, strrpos($table_name, '\\') + 1);
        }
        $this->table_name = strtolower($table_name); // Lowercase convention!
    }

    /**
     * Allows access to other repositories
     * @return \NDBF\RepositoryManager
     */
    final protected function getParent()
    {
        return $this->parent;
    }

    /* ---------------------- Nette\Database EXTENSION ---------------------- */

    /**
     * @return \Nette\Database\Table\Selection
     */
    final public function table()
    {
        return $this->connection->table($this->table_name);
    }

    /**
     * @return \Nette\Database\Table\Selection
     */
    final public function select($columns)
    {
        return $this->connection->table($this->table_name)->select($columns);
    }

    /**
     * Returns all rows as an associative array.
     * @param  string
     * @param  string column name used for an array value or an empty string for the whole row
     * @return array
     */
    public function fetchPairs($key, $val = '')
    {
        return $this->table($this->table_name)->fetchPairs($key, $val);
    }

    /**
     * Counts table's rows.
     * @param array,null $conditions
     * @return int
     */<commit_msg>Repository: select() attribute has default value '*'<commit_after><?php
/**
 * This file is a part of the NDBF library
 *
 * @copyright (c) <NAME> (http://www.slamecka.cz)
 *
 * License can be found within the file license.txt in the root folder.
 *
 */

namespace NDBF;

class Repository extends \Nette\Object
{
    /* ---------------------------- VARIABLES ------------------------------- */

    /** @var \NDBF\RepositoryManager */
    protected $parent;

    /** @var \Nette\Database\Connection */
    protected $connection;

    /** @var string Associated table name */
    protected $table_name;


    /* ------------------------ CONSTRUCTOR, DESIGN ------------------------- */

    public function __construct(RepositoryManager $parent, \Nette\Database\Connection $connection, $table_name = null)
    {
        $this->parent = $parent;
        $this->connection = $connection;

        // DATABASE TABLE NAME
        if ($table_name === null) {
            $table_name = get_class($this);
            $table_name = substr($table_name, strrpos($table_name, '\\') + 1);
        }
        $this->table_name = strtolower($table_name); // Lowercase convention!
    }

    /**
     * Allows access to other repositories
     * @return \NDBF\RepositoryManager
     */
    final protected function getParent()
    {
        return $this->parent;
    }

    /* ---------------------- Nette\Database EXTENSION ---------------------- */

    /**
     * @return \Nette\Database\Table\Selection
     */
    final public function table()
    {
        return $this->connection->table($this->table_name);
    }

    /**
     * @return \Nette\Database\Table\Selection
     */
    final public function select($columns = '*')
    {
        return $this->connection->table($this->table_name)->select($columns);
    }

    /**
     * Returns all rows as an associative array.
     * @param  string
     * @param  string column name used for an array value or an empty string for the whole row
     * @return array
     */
    public function fetchPairs($key, $val = '')
    {
        return $this->table($this->table_name)->fetchPairs($key, $val);
    }

    /**
     * Counts table's rows.
     * @param array,null $conditions
     * @return int
     */
{'fraction_non_alphanumeric': 0.19410042783156947, 'fraction_numerical': 0.00045034902049088043, 'mean_word_length': 1.8565916398713826, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 33, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '2180906', 'n_tokens_mistral': 1258, 'n_tokens_neox': 1209, 'n_words': 310}