Passed
Push — master ( 668ff3...1f2ae2 )
by Yash
03:26
created

DbBackupCommand   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 48
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 2
dl 0
loc 48
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A handle() 0 11 1
1
<?php
2
3
namespace Webelightdev\LaravelDbBackup\Commands;
4
5
use Illuminate\Console\Command;
6
use Webelightdev\LaravelDbBackup\BackupStorage\Backup;
7
use Webelightdev\LaravelDbBackup\BackupStorage\GoogleDrive\Storage;
8
9
class DbBackupCommand extends Command
10
{
11
    protected $backup;
12
    protected $storage;
13
14
    /**
15
     * The name and signature of the console command.
16
     *
17
     * @var string
18
     */
19
    protected $signature = 'dbbackup:run';
20
21
    /**
22
     * The console command description.
23
     *
24
     * @var string
25
     */
26
    protected $description = 'Create Database backup.';
27
28
    /**
29
     * Create a new command instance.
30
     *
31
     * @return void
0 ignored issues
show
Comprehensibility Best Practice introduced by
Adding a @return annotation to constructors is generally not recommended as a constructor does not have a meaningful return value.

Adding a @return annotation to a constructor is not recommended, since a constructor does not have a meaningful return value.

Please refer to the PHP core documentation on constructors.

Loading history...
32
     */
33
    public function __construct(Backup $backup, Storage $storage)
34
    {
35
        parent::__construct();
36
        $this->backup = $backup;
37
        $this->storage = $storage;
38
    }
39
40
    /**
41
     * Execute the console command.
42
     *
43
     * @return mixed
44
     */
45
    public function handle()
46
    {
47
        $backup_file = $this->backup->createBackup();
48
        $this->storage->uploadFile($backup_file);
49
        
50
        // \Mail::send('emails.db_backup_email', compact('current_date'), function ($message) use ($current_date, $dumpfname) {
0 ignored issues
show
Unused Code Comprehensibility introduced by
64% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
51
        //     $message->from(env('MAIL_ADDRESS'), env('MAIL_NAME'));
0 ignored issues
show
Unused Code Comprehensibility introduced by
71% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
52
        //     $message->to(env('MAIL_TO'))->subject('ERP System DB Backup-'.$current_date)->attach($dumpfname);
0 ignored issues
show
Unused Code Comprehensibility introduced by
74% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
53
        // });
54
        unlink($backup_file);
55
    }
56
}
57