<commit_before><?php

namespace Colibri\Query;

use Colibri\Collection\Collection;
use Colibri\Connection\ConnectionInterface;
use Colibri\Query\Expr;
use Colibri\Query\Statement\AbstractStatement;

/**
 * Class Builder
 * @package Colibri\Query
 */
abstract class Builder implements SqlableInterface
{
  
  /**
   * @var bool
   */
  protected $replaceAliases = false;
  
  /**
   * @var null|string
   */
  protected $comment = null;
  
  /**
   * @var ConnectionInterface
   */
  protected $connection = null;
  
  /**
   * @var Expr\Table $table
   */
  
  protected $table = null;
  
  /**
   * @var Collection|Collection[]|Expression[][]
   */
  protected $map = null;
  
  /**
   * @var Collection
   */
  protected $statements;
  
  /**
   * @var bool
   */
  protected $parameterized = false;
  
  /**
   * @var int
   */
  protected $parameterCounter = 0;
  
  /**
   * @var array
   */
  protected $placeholders = [];
  
  /**
   * Builder constructor.
   * @param ConnectionInterface $connection
   */
  public function __construct(ConnectionInterface $connection)
  {
    $this->connection = $connection;
    $this->initialize();
  }
  
  /**
   * Clone operations
   */
  public function __clone()
  {
    $this->map = clone $this->map;
    
    $statements = new Collection();
    foreach ($this->statements as $name => $statement) {
      /** @var AbstractStatement $statement */
      $statement->setBuilder($this);
      $statements->set($name, clone $statement);
    }
    $this->statements = $statements;
  }
  
  /**
   * @return array
   */
  public function __debugInfo()
  {
    return [
      'table' => $this->table->format(),
      'map' => $this->map->toArray(),
    ];
  }
  
  /**
   * The __toString method allows a class to decide how it will react when it is converted to a string.
   *
   * @return string
   * @link http://php.net/manual/en/language.oop5.magic.php#language.oop5.magic.tostring
   */
  function __toString()
  {
    try {
      return $this->toSQL();
    } catch (\Exception $exception) {
      return $exception->getMessage();
    }
  }
  
  /**
   * @return void
   */
  protected function initialize()
  {
    $this->map = new Collection([
      'expressions' => new Collection(),
      'aliases' => new Collection(),
      'hashes' => new Collection(),
    ]);
  }
  
  /**
   * @param $table
   * @return $this
   */
  public function table($table)
  {
    $this->table = $this->completeExpression(new Expr\Table($table));
    
    return $this;<commit_msg>Update Builder.php<commit_after><?php

namespace Colibri\Query;

use Colibri\Collection\Collection;
use Colibri\Connection\ConnectionInterface;
use Colibri\Query\Expr;
use Colibri\Query\Statement\AbstractStatement;

/**
 * Class Builder
 * @package Colibri\Query
 */
abstract class Builder implements SqlableInterface
{
  
  /**
   * @var bool
   */
  protected $replaceAliases = false;
  
  /**
   * @var null|string
   */
  protected $comment = null;
  
  /**
   * @var ConnectionInterface
   */
  protected $connection = null;
  
  /**
   * @var Expr\Table $table
   */
  
  protected $table = null;
  
  /**
   * @var Collection|Collection[]|Expression[][]
   */
  protected $map = null;
  
  /**
   * @var Collection
   */
  protected $statements;
  
  /**
   * @var bool
   */
  protected $parameterized = false;
  
  /**
   * @var int
   */
  protected $parameterCounter = 0;
  
  /**
   * @var array
   */
  protected $placeholders = [];
  
  /**
   * Builder constructor.
   * @param ConnectionInterface $connection
   */
  public function __construct(ConnectionInterface $connection)
  {
    $this->connection = $connection;
    $this->initialize();
  }
  
  /**
   * Clone operations
   */
  public function __clone()
  {
    $this->map = clone $this->map;
    
    $statements = new Collection();
    foreach ($this->statements as $name => $statement) {
      /** @var AbstractStatement $statement */
      $statement->setBuilder($this);
      $statements->set($name, clone $statement);
    }
    $this->statements = $statements;
  }
  
  /**
   * @return array
   */
  public function __debugInfo()
  {
    return [
      'table' => $this->table->format(),
      'map' => $this->map->toArray(),
    ];
  }
  
  /**
   * The __toString method allows a class to decide how it will react when it is converted to a string.
   *
   * @return string
   * @link http://php.net/manual/en/language.oop5.magic.php#language.oop5.magic.tostring
   */
  function __toString()
  {
    try {
      return $this->toSQL();
    } catch (\Exception $exception) {
      return $exception->getMessage();
    }
  }
  
  /**
   * @return void
   */
  protected function initialize()
  {
    $this->map = new Collection([
      'expressions' => new Collection(),
      'aliases' => new Collection(),
      'hashes' => new Collection(),
    ]);
  }
  
  /**
   * @param $table
   * @return $this
   */
  public function table($table)
  {
    $this->table = $this->completeExpression(($table instanceof Expr\Subquery)
      ? $table : new Expr\Table($table));
    
    return $this;
{'fraction_non_alphanumeric': 0.1519086973632428, 'fraction_numerical': 0.0011806375442739079, 'mean_word_length': 2.4719945355191255, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 49, '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': '6117906', 'n_tokens_mistral': 1621, 'n_tokens_neox': 1603, 'n_words': 350}