Migration   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 46.67%

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 3
dl 0
loc 30
ccs 7
cts 15
cp 0.4667
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A configure() 0 8 1
A execute() 0 12 2
1
<?php
2
3
namespace Del\Common\Command;
4
5
use Del\Common\ContainerService;
6
use Doctrine\Migrations\Tools\Console\Command\MigrateCommand;
7
use Symfony\Component\Console\Input\InputInterface;
8
use Symfony\Component\Console\Output\OutputInterface;
9
use Symfony\Component\Console\Input\InputArgument;
10
use Symfony\Component\Console\Input\InputOption;
11
12
class Migration extends MigrateCommand
13
{
14 1
    protected function configure(): void
15
    {
16 1
        parent::configure();
17 1
        $this->setName('migrant');
18 1
        $this->addArgument('vendor', InputArgument::OPTIONAL, 'The vendor directory containing the migrations.');
19 1
        $this->addOption('configuration', null, InputOption::VALUE_OPTIONAL, 'The path to a migrations configuration file.');
20 1
        $this->addOption('db-configuration', null, InputOption::VALUE_OPTIONAL, 'The path to a database connection configuration file.');
21 1
    }
22
23
24
    /**
25
     * @param InputInterface $input
26
     * @param OutputInterface $output
27
     * @return int|null
28
     */
29
    public function execute(InputInterface $input, OutputInterface $output): ?int
30
    {
31
        if ($path = $input->getArgument('vendor')) {
32
            $path = 'vendor/' . $path . '/migrations';
33
            $config = $this->getMigrationConfiguration($input, $output);
34
            $config->setMigrationsDirectory($path);
35
            $config->registerMigrationsFromDirectory($path);
36
            $this->setMigrationConfiguration($config);
37
        }
38
        
39
        return parent::execute($input, $output);
40
    }
41
}
42