Completed
Push — stable7 ( 35746e...825360 )
by
unknown
29:41
created

apps.php ➔ loadDirectory()   B

Complexity

Conditions 6
Paths 6

Size

Total Lines 14
Code Lines 9

Duplication

Lines 0
Ratio 0 %
Metric Value
cc 6
eloc 9
nc 6
nop 1
dl 0
loc 14
rs 8.8571
1
<?php
2
/**
3
 * Copyright (c) 2012 Robin Appelman <[email protected]>
4
 * This file is licensed under the Affero General Public License version 3 or
5
 * later.
6
 * See the COPYING-README file.
7
 */
8
9
function loadDirectory($path) {
10
	if ($dh = opendir($path)) {
11
		while ($name = readdir($dh)) {
12
			if ($name[0] !== '.') {
13
				$file = $path . '/' . $name;
14
				if (is_dir($file)) {
15
					loadDirectory($file);
16
				} elseif (substr($name, -4, 4) === '.php') {
17
					require_once $file;
18
				}
19
			}
20
		}
21
	}
22
}
23
24
function getSubclasses($parentClassName) {
25
	$classes = array();
26
	foreach (get_declared_classes() as $className) {
27
		if (is_subclass_of($className, $parentClassName))
0 ignored issues
show
Bug introduced by
Due to PHP Bug #53727, is_subclass_of might return inconsistent results on some PHP versions if $parentClassName can be an interface. If so, you could instead use ReflectionClass::implementsInterface.
Loading history...
28
			$classes[] = $className;
29
	}
30
31
	return $classes;
32
}
33
34
$apps = OC_App::getEnabledApps();
35
36
foreach ($apps as $app) {
37
	$dir = OC_App::getAppPath($app);
38
	if (is_dir($dir . '/tests')) {
39
		loadDirectory($dir . '/tests');
40
	}
41
}
42