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

CreateCommand::execute()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 5
nc 1
nop 0
dl 0
loc 8
ccs 0
cts 8
cp 0
crap 2
rs 9.4285
c 0
b 0
f 0
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