<commit_before><?php namespace Assaqqaf\Mysqldump\Commands;

use Illuminate\Console\Command;
use Ifsnop\Mysqldump as IMysqldump;

class MysqlDumpCommand extends Command {


    /**
     * The console command name.
     *
     * @var string
     */
    protected $name = 'mysqldump:dump';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = 'Generate a dump.sql in storage path';


    /**
     * Create a new command instance.
     *
     */
    public function __construct()
    {
        parent::__construct();
    }

    /**
     * Execute the console command.
     *
     * @return mixed
     */
    public function fire()
    {
        //@TODO: display some export statistic
        //@TODO: email the result
        //@TODO: store the backup on the cloud
        $this->info('Start Dumping Database' . PHP_EOL);

        $driver = config('database.default');

        if( $driver !== 'mysql'){
            $this->error('Sorry! The package support only MySql!');
            return false;
        }

        $host = config('database.connections.mysql.host');
        $user = config('database.connections.mysql.username');
        $pass = config('database.connections.mysql.password');
        $database = config('database.connections.mysql.database');

        $this->info('Database Metadata:' . $database . PHP_EOL);
        $this->info('Database Name: '.$database);
        $this->info('Database Host: '.$host);
        $this->info('Database User: '.$user);

        $file = storage_path(). "/database/".time()."_dump.sql";

        try {
            $dump = new IMysqldump\Mysqldump($database, $user, $pass);
            $dump->start($file);
        } catch (\Exception $e) {
            $this->error('mysqldump-php error: ' . $e->getMessage());
            return false;
        }
        // IF NECESSARY, YOU CAN ADD exec("sudo mysqldump..... if some there is a permission issue
        //$this->info("mysqldump -h " . $host . " -u " . $user . " -p " . $pass . " --no-create-info " . $name . " > " . $file);
        exec("mysqldump -h " . $host . " -u " . $user . " -p" . $pass . " --no-create-info " . $database . " > " . $file);

        $this->info("Dump file has been created at. " . $file . PHP_EOL);

    }

}<commit_msg>remove duplicated code<commit_after><?php namespace Assaqqaf\Mysqldump\Commands;

use Illuminate\Console\Command;
use Ifsnop\Mysqldump as IMysqldump;

class MysqlDumpCommand extends Command {


    /**
     * The console command name.
     *
     * @var string
     */
    protected $name = 'mysqldump:dump';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = 'Generate a dump.sql in storage path';


    /**
     * Create a new command instance.
     *
     */
    public function __construct()
    {
        parent::__construct();
    }

    /**
     * Execute the console command.
     *
     * @return mixed
     */
    public function fire()
    {
        //@TODO: display some export statistic
        //@TODO: email the result
        //@TODO: store the backup on the cloud
        $this->info('Start Dumping Database' . PHP_EOL);

        $driver = config('database.default');

        if( $driver !== 'mysql'){
            $this->error('Sorry! The package support only MySql!');
            return false;
        }

        $host = config('database.connections.mysql.host');
        $user = config('database.connections.mysql.username');
        $pass = config('database.connections.mysql.password');
        $database = config('database.connections.mysql.database');

        $this->info('Database Metadata:' . $database . PHP_EOL);
        $this->info('Database Name: '.$database);
        $this->info('Database Host: '.$host);
        $this->info('Database User: '.$user);

        $file = storage_path(). "/database/".time()."_dump.sql";

        try {
            $dump = new IMysqldump\Mysqldump($database, $user, $pass);
            $dump->start($file);
        } catch (\Exception $e) {
            $this->error('mysqldump-php error: ' . $e->getMessage());
            return false;
        }
        // IF NECESSARY, YOU CAN ADD exec("sudo mysqldump..... if some there is a permission issue
        //$this->info("mysqldump -h " . $host . " -u " . $user . " -p " . $pass . " --no-create-info " . $name . " > " . $file);
        //exec("mysqldump -h " . $host . " -u " . $user . " -p" . $pass . " --no-create-info " . $database . " > " . $file);

        $this->info("Dump file has been created at. " . $file . PHP_EOL);

    }

}
{'fraction_non_alphanumeric': 0.16112920738327904, 'fraction_numerical': 0.0, 'mean_word_length': 2.0006514657980454, 'pattern_counts': {'":': 0, '<': 5, '<?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': '1863184', 'n_tokens_mistral': 1427, 'n_tokens_neox': 1390, 'n_words': 338}