<commit_before><?php
/*
  * This file is part of the TMS Sync package.
 *
 * (c) <NAME> <<EMAIL>>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */
namespace Flemishartcollection\TMSSync\Database;

use Exception;
use Doctrine\DBAL\Schema\Schema;
use Flemishartcollection\TMSSync\Database\Connection;
use Flemishartcollection\TMSSync\Database\DatabaseInterface;
use Flemishartcollection\TMSSync\Configuration\Configuration as Parameters;
use Flemishartcollection\TMSSync\Filesystem\CSVWriter;
use Monolog\Logger;

/**
 * Source class
 *
 * Represents the "Source" to which the data will be mirrored. This class
 * is an API for the application\console commands. It contains all the core
 * logic needed to interact with a Microsoft SQL database.
 *
 * @author <NAME> <<EMAIL>>
 */
class Source implements DatabaseInterface {
    /**
     * An instance representing the database connection.
     */
    private $connection;

    /**
     * Array of processed configuration variables.
     */
    private $parameters;

    private $logger;

    /**
     * Constructor
     *
     * @param Flemishartcollection\TMSSync\Configuration\Configuration App specific parameters
     */
    public function __construct(Parameters $parameters, Logger $logger) {
        $this->parameters = $parameters->process();
        $this->logger = $logger;
    }

    /**
     * {@inheritdoc}
     */
    public function setConnection(Connection $connection) {
        $this->connection = $connection;
    }

    /**
     * Fetch data from source and store it in CSV files.
     *
     * Each table defined in the "mapping" key as "source" will be queried.
     * For each table, an associated CSV file with "destination" will be
     * created. Each row will be stored in this file. Notes:
     *
     * - Only tables defined as "source" in the "mapping" key will be dumped.
     * - ...
     *
     * @throws Exception An exception if something goes wrong.
     * @return boolean true when the operation was completed succesfully.
     */
    public function fetch() {
        $mapping = $this->parameters['mapping'];
        $tables = $this->parameters['tables'];

        // Group the mappings by 'db' key.
        $databases = array();
        foreach ($mapping as $key => $val) {
            $databases[$val['db']][] = $val;
        }

        // Loop over each database.
        foreach ($databases as $db => $tableMapping) {
            $connection = $this->connection->getConnection($db)

            // Loop over each table mapping
            foreach ($tableMapping as $mapping) {
                $destination = $mapping['destination'];<commit_msg>fixed: typo<commit_after><?php
/*
  * This file is part of the TMS Sync package.
 *
 * (c) <NAME> <<EMAIL>>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */
namespace Flemishartcollection\TMSSync\Database;

use Exception;
use Doctrine\DBAL\Schema\Schema;
use Flemishartcollection\TMSSync\Database\Connection;
use Flemishartcollection\TMSSync\Database\DatabaseInterface;
use Flemishartcollection\TMSSync\Configuration\Configuration as Parameters;
use Flemishartcollection\TMSSync\Filesystem\CSVWriter;
use Monolog\Logger;

/**
 * Source class
 *
 * Represents the "Source" to which the data will be mirrored. This class
 * is an API for the application\console commands. It contains all the core
 * logic needed to interact with a Microsoft SQL database.
 *
 * @author <NAME> <<EMAIL>>
 */
class Source implements DatabaseInterface {
    /**
     * An instance representing the database connection.
     */
    private $connection;

    /**
     * Array of processed configuration variables.
     */
    private $parameters;

    private $logger;

    /**
     * Constructor
     *
     * @param Flemishartcollection\TMSSync\Configuration\Configuration App specific parameters
     */
    public function __construct(Parameters $parameters, Logger $logger) {
        $this->parameters = $parameters->process();
        $this->logger = $logger;
    }

    /**
     * {@inheritdoc}
     */
    public function setConnection(Connection $connection) {
        $this->connection = $connection;
    }

    /**
     * Fetch data from source and store it in CSV files.
     *
     * Each table defined in the "mapping" key as "source" will be queried.
     * For each table, an associated CSV file with "destination" will be
     * created. Each row will be stored in this file. Notes:
     *
     * - Only tables defined as "source" in the "mapping" key will be dumped.
     * - ...
     *
     * @throws Exception An exception if something goes wrong.
     * @return boolean true when the operation was completed succesfully.
     */
    public function fetch() {
        $mapping = $this->parameters['mapping'];
        $tables = $this->parameters['tables'];

        // Group the mappings by 'db' key.
        $databases = array();
        foreach ($mapping as $key => $val) {
            $databases[$val['db']][] = $val;
        }

        // Loop over each database.
        foreach ($databases as $db => $tableMapping) {
            $connection = $this->connection->getConnection($db);

            // Loop over each table mapping
            foreach ($tableMapping as $mapping) {
                $destination = $mapping['destination'];
{'fraction_non_alphanumeric': 0.10553410553410554, 'fraction_numerical': 0.0, 'mean_word_length': 2.7260273972602738, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 35, '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': '4038431', 'n_tokens_mistral': 1452, 'n_tokens_neox': 1421, 'n_words': 496}