<commit_before><?php
/* ===========================================================================
 * Opis Project
 * http://opis.io
 * ===========================================================================
 * Copyright 2013-2015 <NAME>
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * ============================================================================ */

namespace Opis\Database;

use Closure;
use Opis\Database\SQL\Query as QueryCommand;
use Opis\Database\SQL\Insert as InsertCommand;
use Opis\Database\SQL\Update as UpdateCommand;

class Database
{
    /** @var   Connection   Connection instance. */
    protected $connection;

    /** @var    Schema       Schema instance. */
    protected $schema;

    /**
     * Constructor
     *
     * @param   Connection   $connection Connection instance.
     */
    public function __construct(Connection $connection)
    {
        $this->connection = $connection;
    }

    /**
     * Database connection
     *
     * @return   Connection
     */
    public function getConnection(): Connection
    {
        return $this->connection;
    }

    /**
     * Returns the query log for this database.
     *
     * @return array
     */
    public function getLog()
    {
        return $this->connection->getLog();
    }

    /**
     * Execute a query in order to fetch or to delete records.
     *
     * @param   string|array    $tables Table name or an array of tables
     *
     * @return  QueryCommand
     */
    public function from($tables): QueryCommand
    {
        return new QueryCommand($this->connection, $tables);
    }

    /**
     * Insert new records into a table.
     *
     * @param   array  $values  An array of values.
     *
     * @return  InsertCommand
     */
    public function insert(array $values): InsertCommand
    {
        return (new InsertCommand($this->connection))->insert($values);
    }

    /**
     * Update records.
     *
     * @param   string  $table  Table name
     *
     * @return  UpdateCommand
     */
    public function update($table): UpdateCommand
    {
        return new UpdateCommand($this->connection, $table);
    }

    /**
     * The associated schema instance.
     *
     * @return  Schema
     */
    public function schema(): Schema
    {
        if ($this->schema === null) {
            $this->schema = $this->connection->getSchema();
        }

        return $this->schema;
    }

    /**
     * Initiate a new transaction
     *
     * @param callable $queries
     * @return Transaction
     */
    public function transaction(callable $queries): Transaction
    {
        return new Transaction($this, $queries);
    }
}<commit_msg>Updated database class<commit_after><?php
/* ===========================================================================
 * Opis Project
 * http://opis.io
 * ===========================================================================
 * Copyright 2013-2015 <NAME>
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * ============================================================================ */

namespace Opis\Database;

use Opis\Database\SQL\Query as QueryCommand;
use Opis\Database\SQL\Insert as InsertCommand;
use Opis\Database\SQL\Update as UpdateCommand;

class Database
{
    /** @var   Connection   Connection instance. */
    protected $connection;

    /** @var    Schema       Schema instance. */
    protected $schema;

    /**
     * Constructor
     *
     * @param   Connection   $connection Connection instance.
     */
    public function __construct(Connection $connection)
    {
        $this->connection = $connection;
    }

    /**
     * Database connection
     *
     * @return   Connection
     */
    public function getConnection(): Connection
    {
        return $this->connection;
    }

    /**
     * Returns the query log for this database.
     *
     * @return array
     */
    public function getLog()
    {
        return $this->connection->getLog();
    }

    /**
     * Execute a query in order to fetch or to delete records.
     *
     * @param   string|array    $tables Table name or an array of tables
     *
     * @return  QueryCommand
     */
    public function from($tables): QueryCommand
    {
        return new QueryCommand($this->connection, $tables);
    }

    /**
     * Insert new records into a table.
     *
     * @param   array  $values  An array of values.
     *
     * @return  InsertCommand
     */
    public function insert(array $values): InsertCommand
    {
        return (new InsertCommand($this->connection))->insert($values);
    }

    /**
     * Update records.
     *
     * @param   string  $table  Table name
     *
     * @return  UpdateCommand
     */
    public function update($table): UpdateCommand
    {
        return new UpdateCommand($this->connection, $table);
    }

    /**
     * The associated schema instance.
     *
     * @return  Schema
     */
    public function schema(): Schema
    {
        if ($this->schema === null) {
            $this->schema = $this->connection->getSchema();
        }

        return $this->schema;
    }

    /**
     * Initiate a new transaction
     *
     * @param callable $queries
     * @return Transaction
     */
    public function transaction(callable $queries): Transaction
    {
        return new Transaction($this->connection, $queries, $this);
    }
}
{'fraction_non_alphanumeric': 0.16825794334011582, 'fraction_numerical': 0.0037564564094537487, 'mean_word_length': 2.459664320519762, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 32, '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': '5169098', 'n_tokens_mistral': 1660, 'n_tokens_neox': 1593, 'n_words': 515}