Task_DB_Migrate_Down   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 1
dl 0
loc 30
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A _execute() 0 21 3
1
<?php defined('SYSPATH') OR die('No direct script access.');
2
3
/**
4
 * Migrate down the latest migration. Behavior changes when supplied any of the parameters
5
 *
6
 * options:
7
 *  - version: migrate all the way down to the specified migration.
8
 *  - steps: how many times to migrate down
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_Down 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
		$executed = $this->executed_migrations();
22
23
		$up = array();
24
		$down = array();
25
26
		if ($options["version"])
27
		{
28
			if (in_array($options["version"], $executed))
29
			{
30
				$down[] = $options["version"];
31
			}
32
		}
33
		else
34
		{
35
			$down = array_slice($executed, 0, $options['steps']);
36
		}
37
38
		$this->migrate($up, $down, $options['dry-run'] === NULL);
39
	}
40
}
41