Completed
Push — master ( e15c58...b150a8 )
by Changwan
07:08
created

MigrateCreateCommand::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
use Wandu\DI\ContainerInterface;
7
8
class MigrateCreateCommand extends Command
9
{
10
    /** @var string */
11
    protected $description = 'Create a migration file.';
12
13
    /** @var array */
14
    protected $arguments = [
15
        'name' => 'the name for the migration',
16
    ];
17
    
18
    /** @var \Wandu\DI\ContainerInterface */
19
    protected $container;
20
    
21
    /** @var \Wandu\Database\Migrator\MigrateCreator */
22
    protected $creator;
23
24
    /**
25
     * @param \Wandu\DI\ContainerInterface $container
26
     * @param \Wandu\Database\Migrator\MigrateCreator $creator
27
     */
28
    public function __construct(
29
        ContainerInterface $container,
30
        MigrateCreator $creator
31
    ) {
32
        $this->container = $container;
33
        $this->creator = $creator;
34
    }
35
36
    public function execute()
37
    {
38
        $name = $this->input->getArgument('name');
39
        $filePath = $this->creator->create($name);
40
        $this->output->writeln(
41
            '<info>create</info> .' . str_replace($this->container['app_path'], '', $filePath)
42
        );
43
    }
44
}
45