<commit_before><?php

 namespace JSONDb\Classes;

use JSONDb\Classes\Exception;
use JSONDb\Classes\Database;
use JSONDb\Classes\Relation;
use JSONDb\Classes\Helpers;

defined('JSONDB_SECURE') or die('Permission denied!');

 /**
  * Core class of JSONDB project.
  * 
  * There are classes to use JSON files like file database.
  * 
  * Using style was inspired by ORM classes.
  *
  * @category Core
  * @author <NAME>
  * @copyright (c) 2013, <NAME>
  * @license http://opensource.org/licenses/MIT The MIT License
  */
 abstract class Core_Database implements \IteratorAggregate, \Countable {

     /**
      * Contain returned data from file as object or array of objects
      * @var mixed Data from table
      */
     protected $_data;

     /**
      * Name of file (table)
      * @var string Name of table
      */
     protected $_name;

     /**
      * Object with setted data
      * @var object Setted data
      */
     protected $_set;

     /**
      * ID of current row if setted
      * @var integer Current ID
      */
     protected $_current_id;

     /**
      * Key if current row if setted
      * @var integer Current key
      */
     protected $_current_key;

     /**
      * All pending functions parameters in right order
      * @var array
      */
     protected $_pending = array(
         'where' => array(),
         'order_by' => array(),
         'limit' => array(),
         'group_by' => array(),
         'with' => array(),
     );

     /**
      * Information about to reset keys in array or not to
      * @var integer
      */
     protected $_reset_keys = 1;

     /**
      * Factory pattern
      * @param string $name Name of table
      * @return \Jsondb
      * @throws Exception If there's problems with load file
      */
     public static function select($name)
     {
         Helpers\Validate::name($name)->exists();

         $self = new Database;
         $self->_name = $name;

         $self->_set_fields();
//         $self->_data = Helpers\Data::name($self->_name)->get();

         return $self;
     }
     
     protected function _get_data()
     {
         return Helpers\Data::name($this->_name)->get();
     }
     
     protected function _set_data()
     {
         $this->_data = $this->_get_data();
     }

     /**
      * Returns array key of row with specified ID
      * @param integer $id Row ID
      * @return integer Row key
      * @throws Exception If there's no data with that ID
      */
     protected function _get_row_key($id)
     {<commit_msg>Changed select() method [previous factory()] to table()<commit_after><?php

 namespace JSONDb\Classes;

use JSONDb\Classes\Exception;
use JSONDb\Classes\Database;
use JSONDb\Classes\Relation;
use JSONDb\Classes\Helpers;

defined('JSONDB_SECURE') or die('Permission denied!');

 /**
  * Core class of JSONDB project.
  * 
  * There are classes to use JSON files like file database.
  * 
  * Using style was inspired by ORM classes.
  *
  * @category Core
  * @author <NAME>
  * @copyright (c) 2013, <NAME>
  * @license http://opensource.org/licenses/MIT The MIT License
  */
 abstract class Core_Database implements \IteratorAggregate, \Countable {

     /**
      * Contain returned data from file as object or array of objects
      * @var mixed Data from table
      */
     protected $_data;

     /**
      * Name of file (table)
      * @var string Name of table
      */
     protected $_name;

     /**
      * Object with setted data
      * @var object Setted data
      */
     protected $_set;

     /**
      * ID of current row if setted
      * @var integer Current ID
      */
     protected $_current_id;

     /**
      * Key if current row if setted
      * @var integer Current key
      */
     protected $_current_key;

     /**
      * All pending functions parameters in right order
      * @var array
      */
     protected $_pending = array(
         'where' => array(),
         'order_by' => array(),
         'limit' => array(),
         'group_by' => array(),
         'with' => array(),
     );

     /**
      * Information about to reset keys in array or not to
      * @var integer
      */
     protected $_reset_keys = 1;

     /**
      * Factory pattern
      * @param string $name Name of table
      * @return \Jsondb
      * @throws Exception If there's problems with load file
      */
     public static function table($name)
     {
         Helpers\Validate::name($name)->exists();

         $self = new Database;
         $self->_name = $name;

         $self->_set_fields();
//         $self->_data = Helpers\Data::name($self->_name)->get();

         return $self;
     }
     
     protected function _get_data()
     {
         return Helpers\Data::name($this->_name)->get();
     }
     
     protected function _set_data()
     {
         $this->_data = $this->_get_data();
     }

     /**
      * Returns array key of row with specified ID
      * @param integer $id Row ID
      * @return integer Row key
      * @throws Exception If there's no data with that ID
      */
     protected function _get_row_key($id)
     {
{'fraction_non_alphanumeric': 0.11709418445271197, 'fraction_numerical': 0.001958096729978461, 'mean_word_length': 1.9853886616014027, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 37, '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': '3287875', 'n_tokens_mistral': 1475, 'n_tokens_neox': 1435, 'n_words': 462}