Completed
Push — master ( 603a9f...7527cc )
by Changwan
05:44
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
c 0
b 0
f 0
nc 1
nop 0
dl 0
loc 8
ccs 0
cts 8
cp 0
crap 2
rs 9.4285
1
<?php
2
namespace Wandu\Migrator\Commands;
3
4
use Wandu\Console\Command;
5
use Wandu\Migrator\Migrator;
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\Migrator\Migrator */
18
    protected $migrator;
19
20
    public function __construct(Migrator $migrator)
21
    {
22
        $this->migrator = $migrator;
23
    }
24
25
    public function execute()
26
    {
27
        $name = $this->input->getArgument('name');
28
        $filePath = $this->migrator->createTemplate($name);
29
        $this->output->writeln(
30
            '<info>create</info> .' . str_replace(getcwd(), '', $filePath)
31
        );
32
    }
33
}
34