Completed
Push — master ( 4f25b6...e7033c )
by Joao
02:34
created

MigrateCommand   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 49
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
c 1
b 0
f 0
lcom 1
cbo 1
dl 0
loc 49
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A fire() 0 13 2
A addData() 0 4 1
1
<?php namespace jlourenco\support\Commands;
2
3
use Illuminate\Console\Command;
4
use Symfony\Component\Console\Input\InputOption;
5
use Symfony\Component\Console\Input\InputArgument;
6
use File;
7
use jlourenco\support\Helpers\FileLoader;
8
use Setting;
9
use Schema;
10
11
class MigrateCommand extends Command {
12
13
    /**
14
     * The console command name.
15
     *
16
     * @var string
17
     */
18
    protected $name = 'jlourenco:migrate';
19
20
    /**
21
     * The console command description.
22
     *
23
     * @var string
24
     */
25
    protected $description = 'Command to setup all the migrations for the jlourenco packages';
26
27
    /**
28
     * Create a new command instance.
29
     */
30
    public function __construct()
31
    {
32
        parent::__construct();
33
    }
34
35
    /**
36
     * Execute the console command.
37
     *
38
     * @return mixed
39
     */
40
    public function fire()
41
    {
42
        if (!$this->confirm('Running this command will deleted the sentinel users table and add some default data to the jlourenco tables. Are you sure? '))
43
        {
44
            $this->info('Command was aborted by the user.');
45
            return;
46
        }
47
48
        Schema::dropIfExists('users');
49
        $this->addData();
0 ignored issues
show
Unused Code introduced by
The call to the method jlourenco\support\Comman...grateCommand::addData() seems un-needed as the method has no side-effects.

PHP Analyzer performs a side-effects analysis of your code. A side-effect is basically anything that might be visible after the scope of the method is left.

Let’s take a look at an example:

class User
{
    private $email;

    public function getEmail()
    {
        return $this->email;
    }

    public function setEmail($email)
    {
        $this->email = $email;
    }
}

If we look at the getEmail() method, we can see that it has no side-effect. Whether you call this method or not, no future calls to other methods are affected by this. As such code as the following is useless:

$user = new User();
$user->getEmail(); // This line could safely be removed as it has no effect.

On the hand, if we look at the setEmail(), this method _has_ side-effects. In the following case, we could not remove the method call:

$user = new User();
$user->setEmail('email@domain'); // This line has a side-effect (it changes an
                                 // instance variable).
Loading history...
50
51
        $this->info('Command ran successfully');
52
    }
53
54
    private function addData()
55
    {
56
57
    }
58
59
}
60