<commit_before><?php
/**
 *
 *
 * All rights reserved.
 *
 * @author <NAME>
 * @email <EMAIL>
 * @version 1.0
 * @company Studio107
 * @site http://studio107.ru
 * @date 04/01/14.01.2014 03:42
 */

namespace Mindy\Orm;

use ArrayAccess;
use Countable;
use IteratorAggregate;
use Serializable;
use Traversable;

class Manager implements IteratorAggregate, Serializable, Countable, ArrayAccess
{
    /**
     * @var \Mindy\Orm\Model
     */
    protected $_model;

    /**
     * @var \Mindy\Orm\QuerySet
     */
    protected $_qs;

    public function __construct(Model $model)
    {
        $this->_model = $model;
    }

    public function with(array $value)
    {
        $this->getQuerySet()->with($value);
        return $this;
    }

    /**
     * @return Model
     */
    public function getModel()
    {
        return $this->_model;
    }

    /**
     * @return \Mindy\Orm\QuerySet
     */
    public function getQuerySet()
    {
        if ($this->_qs === null) {
            $this->_qs = new QuerySet([
                'model' => $this->getModel(),
                'modelClass' => $this->getModel()->className()
            ]);
        }
        return $this->_qs;
    }

    public function asArray($value = true)
    {
        return $this->getQuerySet()->asArray($value);
    }

    public function asSql($value = true)
    {
        return $this->getQuerySet()->asSql($value);
    }

    public function using($db)
    {
        $this->getQuerySet()->using($db);
        return $this;
    }

    /**
     * Returns the primary key name(s) for this AR class.
     * The default implementation will return the primary key(s) as declared
     * in the DB table that is associated with this AR class.
     *
     * If the DB table does not declare any primary key, you should override
     * this method to return the attributes that you want to use as primary keys
     * for this AR class.
     *
     * Note that an array should be returned even for a table with single primary key.
     *
     * @return string[] the primary keys of the associated database table.
     */
    public function primaryKey()
    {
        return $this->getModel()->getTableSchema()->primaryKey;
    }

    /**
     * @param array $q
     * @return \Mindy\Orm\Manager
     */
    public function filter(array $q)
    {
        $this->getQuerySet()->filter($q);
        return $this;
    }

    /**
     * @param array $q
     * @return \Mindy\Orm\Manager
     */
    public function orFilter(array $q)
    {
        $this->getQuerySet()->orFilter($q);
        return $this;
    }

    /**
     * @param array $q
     * @return \Mindy\Orm\Manager
     */
    public function orExclude(array $q)
    {
        $this->getQuerySet()->orExclude($q);
        return $this;
    }

    /**
     * @param $columns
     * @param null $option
     * @return \Mindy\Orm\Manager
     */
    public function select($columns, $option = null)
    {
        $this->getQuerySet()->select($columns, $option);
        return $this;
    }

    /**
     * @param array $q
     * @return \Mindy\Orm\Manager
     */
    public function exclude(array $q)
    {
        $this->getQuerySet()->exclude($q);
        return $this;
    }

    /**
     * @param array $q
     * @return TreeModel|Model|null
     */
    public function get(array $q = [])
    {
        $this->filter($q);
        return $this->getQuerySet()->get();
    }

    /**
     * @param array $q
     * @return string
     */
    public function getSql(array $q = [])
    {
        $this->filter($q);
        return $this->getQuerySet()->getSql();
    }

    /**
     * @param array $q
     * @return string
     */
    public function getSql(array $q = [])
    {
        return $this->filter($q)->getQuerySet()->getSql();
    }

    /**
     * @return array
     */
    public function all()
    {<commit_msg>Remove duplicate<commit_after><?php
/**
 *
 *
 * All rights reserved.
 *
 * @author <NAME>
 * @email <EMAIL>
 * @version 1.0
 * @company Studio107
 * @site http://studio107.ru
 * @date 04/01/14.01.2014 03:42
 */

namespace Mindy\Orm;

use ArrayAccess;
use Countable;
use IteratorAggregate;
use Serializable;
use Traversable;

class Manager implements IteratorAggregate, Serializable, Countable, ArrayAccess
{
    /**
     * @var \Mindy\Orm\Model
     */
    protected $_model;

    /**
     * @var \Mindy\Orm\QuerySet
     */
    protected $_qs;

    public function __construct(Model $model)
    {
        $this->_model = $model;
    }

    public function with(array $value)
    {
        $this->getQuerySet()->with($value);
        return $this;
    }

    /**
     * @return Model
     */
    public function getModel()
    {
        return $this->_model;
    }

    /**
     * @return \Mindy\Orm\QuerySet
     */
    public function getQuerySet()
    {
        if ($this->_qs === null) {
            $this->_qs = new QuerySet([
                'model' => $this->getModel(),
                'modelClass' => $this->getModel()->className()
            ]);
        }
        return $this->_qs;
    }

    public function asArray($value = true)
    {
        return $this->getQuerySet()->asArray($value);
    }

    public function asSql($value = true)
    {
        return $this->getQuerySet()->asSql($value);
    }

    public function using($db)
    {
        $this->getQuerySet()->using($db);
        return $this;
    }

    /**
     * Returns the primary key name(s) for this AR class.
     * The default implementation will return the primary key(s) as declared
     * in the DB table that is associated with this AR class.
     *
     * If the DB table does not declare any primary key, you should override
     * this method to return the attributes that you want to use as primary keys
     * for this AR class.
     *
     * Note that an array should be returned even for a table with single primary key.
     *
     * @return string[] the primary keys of the associated database table.
     */
    public function primaryKey()
    {
        return $this->getModel()->getTableSchema()->primaryKey;
    }

    /**
     * @param array $q
     * @return \Mindy\Orm\Manager
     */
    public function filter(array $q)
    {
        $this->getQuerySet()->filter($q);
        return $this;
    }

    /**
     * @param array $q
     * @return \Mindy\Orm\Manager
     */
    public function orFilter(array $q)
    {
        $this->getQuerySet()->orFilter($q);
        return $this;
    }

    /**
     * @param array $q
     * @return \Mindy\Orm\Manager
     */
    public function orExclude(array $q)
    {
        $this->getQuerySet()->orExclude($q);
        return $this;
    }

    /**
     * @param $columns
     * @param null $option
     * @return \Mindy\Orm\Manager
     */
    public function select($columns, $option = null)
    {
        $this->getQuerySet()->select($columns, $option);
        return $this;
    }

    /**
     * @param array $q
     * @return \Mindy\Orm\Manager
     */
    public function exclude(array $q)
    {
        $this->getQuerySet()->exclude($q);
        return $this;
    }

    /**
     * @param array $q
     * @return TreeModel|Model|null
     */
    public function get(array $q = [])
    {
        $this->filter($q);
        return $this->getQuerySet()->get();
    }

    /**
     * @param array $q
     * @return string
     */
    public function getSql(array $q = [])
    {
        $this->filter($q);
        return $this->getQuerySet()->getSql();
    }

    /**
     * @return array
     */
    public function all()
    {
{'fraction_non_alphanumeric': 0.14310390645761362, 'fraction_numerical': 0.006377889981397821, 'mean_word_length': 1.9039351851851851, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 84, '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': '6580799', 'n_tokens_mistral': 2389, 'n_tokens_neox': 2305, 'n_words': 578}