Completed
Pull Request — master (#5166)
by Damian
09:53
created

CleanupTestDatabasesTask   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 6

Importance

Changes 1
Bugs 1 Features 0
Metric Value
wmc 4
c 1
b 1
f 0
lcom 0
cbo 6
dl 0
loc 18
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A run() 0 11 4
1
<?php
2
/**
3
 * Cleans up leftover databases from aborted test executions (starting with ss_tmpdb)
4
 * Task is restricted to users with administrator rights or running through CLI.
5
 *
6
 * @package framework
7
 * @subpackage tasks
8
 */
9
class CleanupTestDatabasesTask extends BuildTask {
10
	protected $title = 'Deletes all temporary test databases';
11
12
	protected $description = 'Cleans up leftover databases from aborted test executions (starting with ss_tmpdb)';
13
14
	public function run($request) {
15
		if(!Permission::check('ADMIN') && !Director::is_cli()) {
16
			$response = Security::permissionFailure($this);
17
			if($response) {
18
				$response->output();
19
			}
20
			die;
0 ignored issues
show
Coding Style Compatibility introduced by
The method run() contains an exit expression.

An exit expression should only be used in rare cases. For example, if you write a short command line script.

In most cases however, using an exit expression makes the code untestable and often causes incompatibilities with other libraries. Thus, unless you are absolutely sure it is required here, we recommend to refactor your code to avoid its usage.

Loading history...
21
		}
22
23
		SapphireTest::delete_all_temp_dbs();
24
	}
25
26
}
27