Completed
Branch newinternal (e32466)
by Simon
03:39
created

AutoLoader   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 95.45%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 5
c 1
b 0
f 0
lcom 0
cbo 0
dl 0
loc 35
ccs 21
cts 22
cp 0.9545
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
B load() 0 32 5
1
<?php
2
/******************************************************************************
3
 * Wikipedia Account Creation Assistance tool                                 *
4
 *                                                                            *
5
 * All code in this file is released into the public domain by the ACC        *
6
 * Development Team. Please see team.json for a list of contributors.         *
7
 ******************************************************************************/
8
9
namespace Waca;
10
11
/**
12
 * AutoLoader for the new classes
13
 */
14
class AutoLoader
15
{
16 15
	public static function load($class)
17
	{
18
		// handle namespaces sensibly
19 15
		if (strpos($class, "Waca") !== false) {
20
			// strip off the initial namespace
21 15
			$class = str_replace("Waca\\", "", $class);
22
23
			// swap backslashes for forward slashes to map to directory names
24 15
			$class = str_replace("\\", "/", $class);
25 15
		}
26
27
		$paths = array(
28 15
			__DIR__ . '/' . $class . ".php",
29 15
			__DIR__ . '/DataObjects/' . $class . ".php",
30 15
			__DIR__ . '/Providers/' . $class . ".php",
31 15
			__DIR__ . '/Providers/Interfaces/' . $class . ".php",
32 15
			__DIR__ . '/Validation/' . $class . ".php",
33 15
			__DIR__ . '/Helpers/' . $class . ".php",
34 15
			__DIR__ . '/Helpers/Interfaces/' . $class . ".php",
35 15
			__DIR__ . '/' . $class . ".php",
36 15
		);
37
38 15
		foreach ($paths as $file) {
39 15
			if (file_exists($file)) {
40 15
				require_once($file);
41 15
			}
42
43 15
			if (class_exists($class)) {
44
				return;
45
			}
46 15
		}
47 15
	}
48
}
49