<commit_before><?php
namespace LazyRecord\Schema;
use LazyRecord\Inflector;
use LazyRecord\ConfigLoader;
use Exception;

class SchemaDeclare extends SchemaBase
{

    public $mixins = array();

    public $readSourceId;

    public $writeSourceId;

    public $dataSourceId = 'default';

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

    public function schema() {  }


    public function writeTo( $id ) {
        $this->writeSourceId = $id;
        return $this;
    }

    public function readFrom( $id ) {
        $this->readSourceId = $id;
        return $this;
    }

    /**
     * bootstrap script (to create basedata)
     *
     * @param $record current model object.
     */
    public function bootstrap($record) 
    {

    }


    public function build()
    {

        $this->schema();


        /* find primary key */
        foreach( $this->columns as $name => $column ) {
            if( $column->primary )
                $this->primaryKey = $name;
        }

        if( null === $this->primaryKey && $config = ConfigLoader::getInstance() )
        {
            // XXX: can we prepend ?
            if( $config->loaded && $config->hasAutoId() && ! isset($this->columns['id'] ) ) {
                $this->column('id')
                    ->isa('int')
                    ->integer()
                    ->primary()
                    ->autoIncrement();
                $this->primaryKey = 'id';
            }
        }
    }

    public function export()
    {
        $columnArray = array();
        foreach( $this->columns as $name => $column ) {
            $columnArray[ $name ] = $column->export();
        }

        return array(
            'label'            => $this->getLabel(), // model label
            'table'            => $this->getTable(),
            'columns'          => $columnArray,
            'column_names'     => $this->columnNames,
            'primary_key'      => $this->primaryKey,
            'model_class'      => $this->getModelClass(),
            'collection_class' => $this->getCollectionClass(),
            'relations'      => $this->relations,
            'data_source_id' => $this->dataSourceId,
        );
    }

    public function dump()
    {
        return var_export( $this->export() , true );
    }

    protected function table($table)
    {
        $this->table = $table;
        return $this;<commit_msg>export data source reader,writer attributes.<commit_after><?php
namespace LazyRecord\Schema;
use LazyRecord\Inflector;
use LazyRecord\ConfigLoader;
use Exception;

class SchemaDeclare extends SchemaBase
{

    public $mixins = array();

    public $readSourceId;

    public $writeSourceId;

    public $dataSourceId = 'default';

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

    public function schema() 
    {

    }


    public function writeTo( $id ) 
    {
        $this->writeSourceId = $id;
        return $this;
    }

    public function readFrom( $id ) 
    {
        $this->readSourceId = $id;
        return $this;
    }

    /**
     * bootstrap script (to create basedata)
     *
     * @param $record current model object.
     */
    public function bootstrap($record) 
    {

    }


    public function build()
    {

        $this->schema();


        /* find primary key */
        foreach( $this->columns as $name => $column ) {
            if( $column->primary )
                $this->primaryKey = $name;
        }

        if( null === $this->primaryKey && $config = ConfigLoader::getInstance() )
        {
            // XXX: can we prepend ?
            if( $config->loaded && $config->hasAutoId() && ! isset($this->columns['id'] ) ) {
                $this->column('id')
                    ->isa('int')
                    ->integer()
                    ->primary()
                    ->autoIncrement();
                $this->primaryKey = 'id';
            }
        }
    }

    public function export()
    {
        $columnArray = array();
        foreach( $this->columns as $name => $column ) {
            $columnArray[ $name ] = $column->export();
        }

        return array(
            'label'            => $this->getLabel(), // model label
            'table'            => $this->getTable(),
            'columns'          => $columnArray,
            'column_names'     => $this->columnNames,
            'primary_key'      => $this->primaryKey,
            'model_class'      => $this->getModelClass(),
            'collection_class' => $this->getCollectionClass(),
            'relations'      => $this->relations,
            'read_data_source' => $this->readSourceId,
            'write_data_source' => $this->writeSourceId,
        );
    }

    public function dump()
    {
        return var_export( $this->export() , true );
    }

    protected function table($table)
    {
        $this->table = $table;
        return $this;
{'fraction_non_alphanumeric': 0.14090816534310732, 'fraction_numerical': 0.0, 'mean_word_length': 1.622530699412707, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 85, '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': '6599586', 'n_tokens_mistral': 1397, 'n_tokens_neox': 1333, 'n_words': 293}