Configuration   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 42
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 69.23%

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 3
dl 0
loc 42
ccs 9
cts 13
cp 0.6923
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A getMigrationsToExecute() 0 8 2
A getVersion() 0 6 1
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * This file is part of Zenify
7
 * Copyright (c) 2014 Tomas Votruba (http://tomasvotruba.cz)
8
 */
9
10
namespace Zenify\DoctrineMigrations\Configuration;
11
12
use Doctrine\DBAL\Connection;
13
use Doctrine\DBAL\Migrations\Configuration\Configuration as BaseConfiguration;
14
use Doctrine\DBAL\Migrations\OutputWriter;
15
use Doctrine\DBAL\Migrations\Version;
16
use Nette\DI\Container;
17
18
19
final class Configuration extends BaseConfiguration
20 9
{
21
22 9
	/**
23 9
	 * @var Container
24 9
	 */
25
	private $container;
26
27
28
	public function __construct(Container $container, Connection $connection, OutputWriter $outputWriter = NULL)
29
	{
30
		$this->container = $container;
31
		parent::__construct($connection, $outputWriter);
32 2
	}
33
34 2
35 2
	/**
36 2
	 * @param string $direction
37
	 * @param string $to
38 2
	 */
39
	public function getMigrationsToExecute($direction, $to) : array
40
	{
41
		$versions = parent::getMigrationsToExecute($direction, $to);
42
		foreach ($versions as $version) {
43
			$this->container->callInjects($version->getMigration());
44
		}
45
		return $versions;
46
	}
47
48
49
	/**
50
	 * @param string $version
51
	 * @return Version|string
52
	 */
53
	public function getVersion($version)
54
	{
55
		$version = parent::getVersion($version);
56
		$this->container->callInjects($version->getMigration());
57
		return $version;
58
	}
59
60
}
61