Completed
Push — master ( dc7866...8155ff )
by Changwan
06:46
created

MigrateCreateCommand::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 1
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
namespace Wandu\Database\Commands;
3
4
use Wandu\Console\Command;
5
use Wandu\Database\Migrator\MigrateCreator;
6
7
class MigrateCreateCommand 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