Passed
Pull Request — master (#65)
by Arman
06:20 queued 03:21
created

MigrationGenerateCommand   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 9
c 1
b 0
f 0
dl 0
loc 34
rs 10
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A exec() 0 7 1
1
<?php
2
3
/**
4
 * Quantum PHP Framework
5
 *
6
 * An open source software development framework for PHP
7
 *
8
 * @package Quantum
9
 * @author Arman Ag. <[email protected]>
10
 * @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org)
11
 * @link http://quantum.softberg.org/
12
 * @since 2.7.0
13
 */
14
15
namespace Quantum\Console\Commands;
16
17
use Quantum\Migration\MigrationManager;
18
use Quantum\Console\QtCommand;
19
20
/**
21
 * Class MigrationCreateCommand
22
 * @package Quantum\Console\Commands
23
 */
24
class MigrationGenerateCommand extends QtCommand
25
{
26
27
    /**
28
     * The console command name.
29
     * @var string
30
     */
31
    protected $name = 'migration:generate';
32
33
    /**
34
     * The console command description.
35
     * @var string
36
     */
37
    protected $description = 'Generates new migration file';
38
39
    /**
40
     * Command arguments
41
     * @var \string[][]
42
     */
43
    protected $args = [
44
        ['action', 'required', 'The action to perform. [create] for creating table, [alter] for altering table, [rename] for renaming table, [drop] for dropping table'],
45
        ['table', 'required', 'The table name'],
46
    ];
47
48
    /**
49
     * Executes the command
50
     */
51
    public function exec()
52
    {
53
        $migrationManager = new MigrationManager();
54
55
        $migrationName = $migrationManager->generateMigration($this->getArgument('table'), $this->getArgument('action'));
56
57
        $this->info('Migration file ' . $migrationName . ' successfully created');
58
    }
59
60
}
61