Completed
Push — master ( b31514...603a9f )
by Changwan
06:16
created

CreateCommand   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
dl 0
loc 27
ccs 0
cts 12
cp 0
rs 10
c 0
b 0
f 0
wmc 2
lcom 1
cbo 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A execute() 0 8 1
1
<?php
2
namespace Wandu\Database\Migrator\Commands;
3
4
use Wandu\Console\Command;
5
use Wandu\Database\Migrator\MigrateCreator;
6
7
class CreateCommand extends Command
8
{
9
    /** @var string */
10
    protected $description = 'Create a migration file.';
11
12
    /** @var array */
13
    protected $arguments = [
14
        'name' => 'the name for the migration',
15
    ];
16
    
17
    /** @var \Wandu\Database\Migrator\MigrateCreator */
18
    protected $creator;
19
20
    public function __construct(MigrateCreator $creator)
21
    {
22
        $this->creator = $creator;
23
    }
24
25
    public function execute()
26
    {
27
        $name = $this->input->getArgument('name');
28
        $filePath = $this->creator->create($name);
29
        $this->output->writeln(
30
            '<info>create</info> .' . str_replace(getcwd(), '', $filePath)
31
        );
32
    }
33
}
34