Completed
Push — stable8.1 ( 7a1b8f...6080a3 )
by
unknown
107:52
created

apps.php ➔ getSubclasses()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 9
Code Lines 6

Duplication

Lines 0
Ratio 0 %
Metric Value
cc 3
eloc 6
nc 3
nop 1
dl 0
loc 9
rs 9.6666
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 (strpos($path, 'integration')) {
11
		return;
12
	}
13
	if ($dh = opendir($path)) {
14
		while ($name = readdir($dh)) {
15
			if ($name[0] !== '.') {
16
				$file = $path . '/' . $name;
17
				if (is_dir($file)) {
18
					loadDirectory($file);
19
				} elseif (substr($name, -4, 4) === '.php') {
20
					require_once $file;
21
				}
22
			}
23
		}
24
	}
25
}
26
27
function getSubclasses($parentClassName) {
28
	$classes = array();
29
	foreach (get_declared_classes() as $className) {
30
		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...
31
			$classes[] = $className;
32
	}
33
34
	return $classes;
35
}
36
37
$apps = OC_App::getEnabledApps();
38
39
foreach ($apps as $app) {
40
	$dir = OC_App::getAppPath($app);
41
	if (is_dir($dir . '/tests')) {
42
		loadDirectory($dir . '/tests');
43
	}
44
}
45