<commit_before><?php

namespace MadeSimple\Database;

use Psr\Log\LoggerAwareTrait;
use Psr\Log\LoggerInterface;
use Psr\Log\NullLogger;

abstract class Builder
{
    use ConnectionAwareTrait, LoggerAwareTrait;

    /**
     * @var array
     */
    protected $statement = [];

    /**
     * Builder constructor.
     *
     * @param Connection|null      $connection
     * @param LoggerInterface|null $logger
     */
    public function __construct(Connection $connection = null, LoggerInterface $logger = null)
    {
        $this->setConnection($connection);
        $this->setLogger($logger ?? new NullLogger);
        if (method_exists($this, 'setPdo')) {
            $this->setPdo($connection->pdo);
        }
        if (method_exists($this, 'setCompiler')) {
            $this->setCompiler($connection->compiler);
        }
    }

    /**
     * Add to the statement.
     *
     * @param string      $section
     * @param mixed|array $value
     *
     * @return static
     */
    protected function addToStatement($section, $value)
    {
        $value = (array) $value;

        if (!array_key_exists($section, $this->statement)) {
            $this->statement[$section] = $value;
        } else {
            $this->statement[$section] = array_merge($this->statement[$section], $value);
        }

        return $this;
    }
}<commit_msg>* Builder now implements Arrayable to allow access to underlining statement array<commit_after><?php

namespace MadeSimple\Database;

use MadeSimple\Arrays\Arrayable;
use Psr\Log\LoggerAwareTrait;
use Psr\Log\LoggerInterface;
use Psr\Log\NullLogger;

abstract class Builder implements Arrayable
{
    use ConnectionAwareTrait, LoggerAwareTrait;

    /**
     * @var array
     */
    protected $statement = [];

    /**
     * Builder constructor.
     *
     * @param Connection|null      $connection
     * @param LoggerInterface|null $logger
     */
    public function __construct(Connection $connection = null, LoggerInterface $logger = null)
    {
        $this->setConnection($connection);
        $this->setLogger($logger ?? new NullLogger);
        if (method_exists($this, 'setPdo')) {
            $this->setPdo($connection->pdo);
        }
        if (method_exists($this, 'setCompiler')) {
            $this->setCompiler($connection->compiler);
        }
    }

    /**
     * Add to the statement.
     *
     * @param string      $section
     * @param mixed|array $value
     *
     * @return static
     */
    protected function addToStatement($section, $value)
    {
        $value = (array) $value;

        if (!array_key_exists($section, $this->statement)) {
            $this->statement[$section] = $value;
        } else {
            $this->statement[$section] = array_merge($this->statement[$section], $value);
        }

        return $this;
    }

    /**
     * @return array
     */
    public function toArray()
    {
        return $this->statement;
    }
}
{'fraction_non_alphanumeric': 0.13217804960924226, 'fraction_numerical': 0.0, 'mean_word_length': 2.330316742081448, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 24, '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': '4463088', 'n_tokens_mistral': 846, 'n_tokens_neox': 835, 'n_words': 176}