DbBackupCommand   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 43
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A handle() 0 6 1
1
<?php
2
3
namespace Webelightdev\LaravelDbBackup\Commands;
4
5
use Illuminate\Console\Command;
6
use Webelightdev\LaravelDbBackup\BackupStorage\Backup;
7
8
class DbBackupCommand extends Command
9
{
10
    protected $backup;
11
    protected $storage;
12
13
    /**
14
     * The name and signature of the console command.
15
     *
16
     * @var string
17
     */
18
    protected $signature = 'run:dbbackup';
19
20
    /**
21
     * The console command description.
22
     *
23
     * @var string
24
     */
25
    protected $description = 'Create Database backup.';
26
27
    /**
28
     * Create a new command instance.
29
     *
30
     * @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...
31
     */
32
    public function __construct(Backup $backup, Storage $storage)
33
    {
34
        parent::__construct();
35
        $this->backup = $backup;
36
        $this->storage = $storage;
37
    }
38
39
    /**
40
     * Execute the console command.
41
     *
42
     * @return mixed
43
     */
44
    public function handle()
45
    {
46
        $backup_file = $this->backup->createBackup();
47
        $this->storage->uploadFile($backup_file);
48
        unlink($backup_file);
49
    }
50
}
51