Completed
Pull Request — master (#32)
by Tomáš
10:51 queued 08:25
created

Configuration::getMigrationsToExecute()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 2

Importance

Changes 2
Bugs 0 Features 1
Metric Value
c 2
b 0
f 1
dl 0
loc 8
ccs 5
cts 5
cp 1
rs 9.4285
cc 2
eloc 5
nc 2
nop 2
crap 2
1
<?php
2
3
/*
4
 * This file is part of Zenify
5
 * Copyright (c) 2014 Tomas Votruba (http://tomasvotruba.cz)
6
 */
7
8
namespace Zenify\DoctrineMigrations\Configuration;
9
10
use Doctrine\DBAL\Connection;
11
use Doctrine\DBAL\Migrations\Configuration\Configuration as BaseConfiguration;
12
use Doctrine\DBAL\Migrations\OutputWriter;
13
use Doctrine\DBAL\Migrations\Version;
14
use Nette\DI\Container;
15
16
17
final class Configuration extends BaseConfiguration
18
{
19
20 9
	public function __construct(Container $container, Connection $connection, OutputWriter $outputWriter = NULL)
21
	{
22 9
		$this->container = $container;
0 ignored issues
show
Bug introduced by
The property container does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
23 9
		parent::__construct($connection, $outputWriter);
24 9
	}
25
26
27
	/**
28
	 * @param string $direction
29
	 * @param string $to
30
	 * @return Version[]
31
	 */
32 2
	public function getMigrationsToExecute($direction, $to)
33
	{
34 2
		$versions = parent::getMigrationsToExecute($direction, $to);
35 2
		foreach ($versions as $version) {
36 2
			$this->container->callInjects($version->getMigration());
37
		}
38 2
		return $versions;
39
	}
40
41
42
	/**
43
	 * @param string $version
44
	 * @return Version|string
45
	 */
46
	public function getVersion($version)
47
	{
48
		$version = parent::getVersion($version);
49
		$this->container->callInjects($version->getMigration());
50
		return $version;
51
	}
52
53
}
54