Configuration::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 1
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 5
ccs 1
cts 1
cp 1
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 3
crap 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