CreateCommand::configure()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 12
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 1
eloc 9
nc 1
nop 0
dl 0
loc 12
ccs 0
cts 9
cp 0
crap 2
rs 9.9666
c 1
b 0
f 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace ByTIC\Migrations\Console;
6
7
use ByTIC\Console\Command;
8
use Exception;
9
use Symfony\Component\Console\Input\InputArgument;
10
use Symfony\Component\Console\Input\InputInterface;
11
use Symfony\Component\Console\Output\OutputInterface;
12
13
/**
14
 * Class CreateCommand
15
 * @package ByTIC\Migrations\Console
16
 */
17
class CreateCommand extends Command
18
{
19
    protected function configure()
20
    {
21
        parent::configure();
22
        $this->setName('migrations:create');
23
24
        $this->setDescription('Create a new migration')
25
            ->addArgument('name', InputArgument::OPTIONAL, 'Class name of the migration (in CamelCase)')
26
            ->setHelp(
27
                sprintf(
28
                    '%sCreates a new database migration%s',
29
                    PHP_EOL,
30
                    PHP_EOL
31
                )
32
            );
33
    }
34
35
    /**
36
     * @inheritDoc
37
     * @noinspection PhpMissingParentCallCommonInspection
38
     * @throws Exception
39
     */
40
    protected function execute(InputInterface $input, OutputInterface $output): int
41
    {
42
        $migrator = migrator();
43
        return $migrator->create($input->getArguments(), $output);
44
    }
45
}
46