Failed Conditions
Pull Request — master (#2)
by Herberto
11:45
created

MigrationsExecutor::execute()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
cc 2
eloc 2
nc 2
nop 1
dl 0
loc 4
ccs 0
cts 3
cp 0
crap 6
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Hgraca\DoctrineTestDbRegenerationBundle\Doctrine;
6
7
use Doctrine\Bundle\MigrationsBundle\Command\DoctrineCommand;
8
use Doctrine\DBAL\Connection;
9
use Doctrine\DBAL\Migrations\Configuration\Configuration;
10
use Symfony\Component\DependencyInjection\ContainerInterface;
11
12
final class MigrationsExecutor implements MigrationsExecutorInterface
13
{
14
    const UP = 'up';
15
16
    /**
17
     * @var Configuration
18
     */
19
    private $config;
20
21
    /**
22
     * @throws \ErrorException
23
     */
24
    public function __construct(ContainerInterface $container, Connection $connection)
25
    {
26
        $this->config = new Configuration($connection);
27
        DoctrineCommand::configureMigrations($container, $this->config);
28
    }
29
30
    /**
31
     * @throws \Doctrine\DBAL\Migrations\MigrationException
32
     * @throws \Exception
33
     */
34
    public function execute(string ...$versionList): void
35
    {
36
        foreach ($versionList as $version) {
37
            $this->config->getVersion($version)->execute(self::UP);
38
        }
39
    }
40
}
41