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

MigrationsExecutor   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
dl 0
loc 26
ccs 0
cts 7
cp 0
rs 10
c 0
b 0
f 0
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A execute() 0 4 2
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