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.
Completed
Push — master ( 00b768...e1065b )
by Shea
02:28
created

ModuleMigrateRollbackCommand::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 3
Bugs 1 Features 1
Metric Value
c 3
b 1
f 1
dl 0
loc 6
rs 9.4286
cc 1
eloc 3
nc 1
nop 1
1
<?php
2
namespace Caffeinated\Modules\Console\Commands;
3
4
use Caffeinated\Modules\Modules;
5
use Caffeinated\Modules\Traits\MigrationTrait;
6
use Illuminate\Console\ConfirmableTrait;
7
use Illuminate\Console\Command;
8
use Symfony\Component\Console\Input\InputOption;
9
use Symfony\Component\Console\Input\InputArgument;
10
11
class ModuleMigrateRollbackCommand extends Command
12
{
13
	use MigrationTrait, ConfirmableTrait;
14
15
    /**
16
     * The console command name.
17
     *
18
     * @var string
19
     */
20
	protected $name = 'module:migrate:rollback';
21
22
    /**
23
     * The console command description.
24
     *
25
     * @var string
26
     */
27
	protected $description = 'Rollback the last database migrations for a specific or all modules';
28
29
	/**
30
	 * @var Modules
31
	 */
32
	protected $module;
33
34
	/**
35
	 * Create a new command instance.
36
	 *
37
	 * @param Modules  $module
38
	 */
39
	public function __construct(Modules $module)
40
	{
41
		parent::__construct();
42
43
		$this->module = $module;
44
	}
45
46
	/**
47
	 * Execute the console command.
48
	 *
49
	 * @return mixed
50
	 */
51
	public function fire()
52
	{
53
        if (! $this->confirmToProceed()) return null;
54
55
		$slug = $this->argument('slug');
56
57
		if ($slug) {
58
			return $this->rollback($Slug);
0 ignored issues
show
Bug introduced by
The variable $Slug does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
59
		} else {
60
			foreach ($this->module->all() as $module) {
61
				$this->rollback($module['slug']);
62
			}
63
		}
64
	}
65
66
	/**
67
	 * Run the migration rollback for the specified module.
68
	 *
69
	 * @param string  $slug
70
	 * @return mixed
71
	 */
72
	protected function rollback($slug)
73
	{
74
		$this->requireMigrations($slug);
75
76
		$this->call('migrate:rollback', [
77
			'--database' => $this->option('database'),
78
			'--force'    => $this->option('force'),
79
			'--pretend'  => $this->option('pretend'),
80
		]);
81
	}
82
83
	/**
84
	 * Get the console command arguments.
85
	 *
86
	 * @return array
87
	 */
88
	protected function getArguments()
89
	{
90
		return [['slug', InputArgument::OPTIONAL, 'Module slug.']];
91
	}
92
93
	/**
94
	 * Get the console command options.
95
	 *
96
	 * @return array
97
	 */
98
	protected function getOptions()
99
	{
100
		return [
101
			['database', null, InputOption::VALUE_OPTIONAL, 'The database connection to use.'],
102
			['force', null, InputOption::VALUE_NONE, 'Force the operation to run while in production.'],
103
			['pretend', null, InputOption::VALUE_NONE, 'Dump the SQL queries that would be run.']
104
		];
105
	}
106
}
107