GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

GeneratorCommand   A
last analyzed

Complexity

Total Complexity 8

Size/Duplication

Total Lines 97
Duplicated Lines 0 %

Coupling/Cohesion

Components 2
Dependencies 2

Importance

Changes 0
Metric Value
wmc 8
c 0
b 0
f 0
lcom 2
cbo 2
dl 0
loc 97
rs 10

6 Methods

Rating   Name   Duplication   Size   Complexity  
A getDatabaseName() 0 7 1
A blockMessage() 0 11 1
A sectionMessage() 0 9 1
A getArguments() 0 10 1
A getOptions() 0 12 1
A fireAction() 0 16 3
1
<?php
2
3
namespace Elimuswift\DbExporter\Commands;
4
5
use Config;
6
use Illuminate\Console\Command;
7
use Elimuswift\DbExporter\DbExporter;
8
use Symfony\Component\Console\Input\InputOption;
9
use Symfony\Component\Console\Input\InputArgument;
10
11
class GeneratorCommand extends Command
12
{
13
    /**
14
     * Current database being exported or migrated.
15
     *
16
     * @var string
17
     **/
18
    protected $database;
19
20
    /**
21
     * Get the database name from the app/config/database.php file.
22
     *
23
     * @return string
24
     */
25
    protected function getDatabaseName()
26
    {
27
        $connType = Config::get('database.default');
28
        $database = Config::get('database.connections.' . $connType);
29
30
        return $database['database'];
31
    }
32
33
//end getDatabaseName()
34
35
    protected function blockMessage($title, $message, $style = 'info')
36
    {
37
        // Symfony style block messages
38
        $formatter = $this->getHelperSet()->get('formatter');
39
        $errorMessages = [
40
                            $title,
41
                            $message,
42
                            ];
43
        $formattedBlock = $formatter->formatBlock($errorMessages, $style, true);
44
        $this->line($formattedBlock);
45
    }
46
47
//end blockMessage()
48
49
    protected function sectionMessage($title, $message)
50
    {
51
        $formatter = $this->getHelperSet()->get('formatter');
52
        $formattedLine = $formatter->formatSection(
53
            $title,
54
            $message
55
        );
56
        $this->line($formattedLine);
57
    }
58
59
//end sectionMessage()
60
61
    protected function getArguments()
62
    {
63
        return [
64
                [
65
                    'database',
66
                    InputArgument::OPTIONAL,
67
                    'Override the application database',
68
                ],
69
                ];
70
    }
71
72
//end getArguments()
73
74
    protected function getOptions()
75
    {
76
        return [
77
                [
78
                    'ignore',
79
                    'i',
80
                    InputOption::VALUE_REQUIRED,
81
                    'Ignore tables to export, seperated by a comma',
82
                    null,
83
                ],
84
                ];
85
    }
86
87
//end getOptions()
88
89
    protected function fireAction($action, $database)
90
    {
91
        // Grab the options
92
        $ignore = $this->option('ignore');
93
        $this->database = $database;
94
        if (empty($ignore)) {
95
            $this->handler->$action($database);
0 ignored issues
show
Bug introduced by
The property handler does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
96
        } else {
97
            $tables = explode(',', str_replace(' ', '', $ignore));
98
            DbExporter::$ignore = array_merge(DbExporter::$ignore, $tables);
99
            $this->handler->$action($database);
100
            foreach ($tables as $table) {
101
                $this->comment("Ignoring the {$table} table");
102
            }
103
        }
104
    }
105
106
//end fireAction()
107
}//end class
108