<commit_before><?php
/*
 * This file is a part of Solve framework.
 *
 * @author <NAME> <<EMAIL>>
 * @copyright 2009-2014, <NAME>
 * created: 05.10.14 09:13
 */

namespace Solve\Database\Models;

use Solve\Database\QC;
use Solve\Utils\Inflector;

/**
 * Class ModelCollection
 * @package Solve\Database\Models
 *
 * Class ModelCollection is used to operate with collection of models
 *
 * @method _setRawFieldValue($field, $value)
 * @method _setRawFieldData($data)
 *
 * @version 1.0
 * @author <NAME> <<EMAIL>>
 */
class ModelCollection implements \ArrayAccess, \IteratorAggregate, \Countable {

    private $_data   = array();
    private $_pk_map = array();
    /**
     * @var Model
     */
    private $_model;
    /**
     * @var ModelStructure
     */
    private $_structure;
    private $_modelClass;
    private $_tableName;
    private $_primaryKey;
    private $_modelsMethods = array(
        '_setRawFieldValue', '_setRawFieldData'
    );

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

    /**
     * @param Model $modelObject
     */
    public function _setModel($modelObject) {
        if (!is_object($modelObject)) $modelObject = new $modelObject();
        $this->_model      = $modelObject;
        $this->_modelClass = get_class($modelObject);
        $this->_structure  = $modelObject->_getStructure();
        $this->_tableName  = $this->_structure->getTableName();
        $this->_primaryKey = $this->_structure->getPrimaryKey();
    }

    /**
     * @param QC|mixed $criteria
     * @param Model $modelObject
     * @return ModelCollection
     */
    public static function loadList($criteria, $modelObject) {
        $className = get_called_class();
        /**<commit_msg>protected props<commit_after><?php
/*
 * This file is a part of Solve framework.
 *
 * @author <NAME> <<EMAIL>>
 * @copyright 2009-2014, <NAME>
 * created: 05.10.14 09:13
 */

namespace Solve\Database\Models;

use Solve\Database\QC;
use Solve\Utils\Inflector;

/**
 * Class ModelCollection
 * @package Solve\Database\Models
 *
 * Class ModelCollection is used to operate with collection of models
 *
 * @method _setRawFieldValue($field, $value)
 * @method _setRawFieldData($data)
 *
 * @version 1.0
 * @author <NAME> <<EMAIL>>
 */
class ModelCollection implements \ArrayAccess, \IteratorAggregate, \Countable {

    protected $_data   = array();
    protected $_pk_map = array();
    /**
     * @var Model
     */
    protected $_model;
    /**
     * @var ModelStructure
     */
    protected $_structure;
    protected $_modelClass;
    protected $_tableName;
    protected $_primaryKey;
    protected $_modelsMethods = array(
        '_setRawFieldValue', '_setRawFieldData'
    );

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

    /**
     * @param Model $modelObject
     */
    public function _setModel($modelObject) {
        if (!is_object($modelObject)) $modelObject = new $modelObject();
        $this->_model      = $modelObject;
        $this->_modelClass = get_class($modelObject);
        $this->_structure  = $modelObject->_getStructure();
        $this->_tableName  = $this->_structure->getTableName();
        $this->_primaryKey = $this->_structure->getPrimaryKey();
    }

    /**
     * @param QC|mixed $criteria
     * @param Model $modelObject
     * @return ModelCollection
     */
    public static function loadList($criteria, $modelObject) {
        $className = get_called_class();
        /**
{'fraction_non_alphanumeric': 0.13709677419354838, 'fraction_numerical': 0.01152073732718894, 'mean_word_length': 2.9022471910112357, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 39, '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': '2819702', 'n_tokens_mistral': 1054, 'n_tokens_neox': 1005, 'n_words': 239}