<commit_before><?php

/*
 * This file is part of Laravel Backup.
 *
 * (c) <NAME> <<EMAIL>>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Vinkla\Backup\Sources;

use Illuminate\Contracts\Config\Repository;
use InvalidArgumentException;
use Vinkla\Backup\FactoryInterface;
use Zenstruck\Backup\Source\MySqlDumpSource;

/**
 * This is the database source class.
 *
 * @author <NAME> <<EMAIL>>
 */
class DatabaseSource implements FactoryInterface
{
    /**
     * The config repository instance.
     *
     * @var \Illuminate\Contracts\Config\Repository
     */
    protected $config;

    /**
     * Create a new database source instance.
     *
     * @param \Illuminate\Contracts\Config\Repository $config
     *
     * @return void
     */
    public function __construct(Repository $config)
    {
        $this->config = $config;
    }

    /**
     * Bootstrap the source.
     *
     * @throws \InvalidArgumentException
     *
     * @return \Zenstruck\Backup\Source\MySqlDumpSource
     */
    public function bootstrap()
    {
        $connection = $this->getDatabaseConnection();

        $config = $this->config->get("database.connections.$connection");

        if ($config['driver'] !== 'mysql') {
            throw new InvalidArgumentException("Unsupported database driver [{$config['driver']}].");
        }

        return new MySqlDumpSource($this->getName(), $config['database'], $config['host'], $config['username'], $config['password']);
    }

    /**
     * Get the database driver.
     *
     * @return string
     */
    public function getDatabaseConnection()
    {
        return $this->config->get('database.default');
    }

    /**
     * Get the source name.
     *
     * @return string
     */
    public function getName()
    {
        return 'database';
    }
}<commit_msg>Use array get helper<commit_after><?php

/*
 * This file is part of Laravel Backup.
 *
 * (c) <NAME> <<EMAIL>>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Vinkla\Backup\Sources;

use Illuminate\Contracts\Config\Repository;
use InvalidArgumentException;
use Vinkla\Backup\FactoryInterface;
use Zenstruck\Backup\Source\MySqlDumpSource;

/**
 * This is the database source class.
 *
 * @author <NAME> <<EMAIL>>
 */
class DatabaseSource implements FactoryInterface
{
    /**
     * The config repository instance.
     *
     * @var \Illuminate\Contracts\Config\Repository
     */
    protected $config;

    /**
     * Create a new database source instance.
     *
     * @param \Illuminate\Contracts\Config\Repository $config
     *
     * @return void
     */
    public function __construct(Repository $config)
    {
        $this->config = $config;
    }

    /**
     * Bootstrap the source.
     *
     * @throws \InvalidArgumentException
     *
     * @return \Zenstruck\Backup\Source\MySqlDumpSource
     */
    public function bootstrap()
    {
        $connection = $this->getDatabaseConnection();

        $config = $this->config->get("database.connections.$connection");

        if (array_get($config, 'driver') !== 'mysql') {
            throw new InvalidArgumentException("Unsupported database driver [{$config['driver']}].");
        }

        return new MySqlDumpSource(
            $this->getName(),
            array_get($config, 'database'),
            array_get($config, 'host'),
            array_get($config, 'username'),
            array_get($config, 'password')
        );
    }

    /**
     * Get the database driver.
     *
     * @return string
     */
    public function getDatabaseConnection()
    {
        return $this->config->get('database.default');
    }

    /**
     * Get the source name.
     *
     * @return string
     */
    public function getName()
    {
        return 'database';
    }
}
{'fraction_non_alphanumeric': 0.12905679513184584, 'fraction_numerical': 0.0, 'mean_word_length': 2.445414847161572, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 29, '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': '7125404', 'n_tokens_mistral': 1103, 'n_tokens_neox': 1099, 'n_words': 269}