Task_DB_Migrate_Up::_execute()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 21
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 21
rs 9.3142
c 0
b 0
f 0
nc 3
cc 3
eloc 10
nop 1
1
<?php defined('SYSPATH') OR die('No direct script access.');
2
3
/**
4
 * Migrate up the first unexecuted migration. Behavior changes when supplied any of the parameters
5
 *
6
 * options:
7
 *  - version: migrate all the way up to the specified migration.
8
 *  - steps: how many times to migrate up
9
 *  - dry-run: if this flag is set, will run the migration without accually touching the database, only showing the result.
10
 */
11
class Task_DB_Migrate_Up extends Minion_Migration {
12
13
	protected $_options = array(
14
		'version' => NULL,
15
		'steps' => 1,
16
		'dry-run' => FALSE
17
	);
18
19
	protected function _execute(array $options)
20
	{
21
		$unexecuted = $this->unexecuted_migrations();
22
23
		$up = array();
24
		$down = array();
25
26
		if ($options["version"])
27
		{
28
			if (in_array($options["version"], $unexecuted))
29
			{
30
				$up[] = $options["version"];
31
			}
32
		}
33
		else
34
		{
35
			$up = array_slice($unexecuted, 0, $options['steps']);
36
		}
37
38
		$this->migrate($up, $down, $options['dry-run'] === NULL);
39
	}
40
}
41