MapsRegistration   A
last analyzed

Complexity

Total Complexity 8

Size/Duplication

Total Lines 52
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
wmc 8
lcom 0
cbo 1
dl 0
loc 52
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
B onRegistration() 0 48 8
1
<?php
2
3
use Maps\MapsSetup;
4
5
class MapsRegistration {
6
7
	public static function onRegistration( array $credits ) {
8
		if ( defined( 'Maps_VERSION' ) ) {
9
			// Do not initialize more than once.
10
			return true;
11
		}
12
13
		if ( !defined( 'Maps_SETTINGS_LOADED' ) ) {
14
			require_once __DIR__ . '/Maps_Settings.php';
15
		}
16
17
		if ( is_readable( __DIR__ . '/vendor/autoload.php' ) ) {
18
			include_once( __DIR__ . '/vendor/autoload.php' );
19
		}
20
21
		define( 'Maps_VERSION', $credits['version'] );
22
		define( 'SM_VERSION', Maps_VERSION );
23
24
		if ( !(bool)'Defining PHP constants in JSON is a bad idea and breaks tools' ) {
25
			define( 'NS_GEO_JSON', 420 );
26
			define( 'NS_GEO_JSON_TALK', 421 );
27
		}
28
29
		$GLOBALS['wgHooks']['SMW::Settings::BeforeInitializationComplete'][] = 'Maps\MapsHooks::addSmwSettings';
30
31
		$GLOBALS['wgExtensionFunctions'][] = function() {
32
			if ( $GLOBALS['egMapsDisableExtension'] ) {
33
				return true;
34
			}
35
36
			// Only initialize the extension when all dependencies are present.
37
			if ( !defined( 'Validator_VERSION' ) ) {
38
				throw new Exception( 'You need to have Validator installed in order to use Maps' );
39
			}
40
41
			if ( version_compare( $GLOBALS['wgVersion'], '1.31c', '<' ) ) {
42
				throw new Exception(
43
					'This version of Maps requires MediaWiki 1.31 or above; use Maps 5.6.x for older versions.'
44
					. ' More information at https://github.com/JeroenDeDauw/Maps/blob/master/INSTALL.md'
45
				);
46
			}
47
48
			( new MapsSetup( $GLOBALS ) )->setup();
49
50
			return true;
51
		};
52
53
		return true;
54
	}
55
56
}
57
58
59
60