ModernTimelineSetup::onExtensionFunction()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 4
ccs 0
cts 3
cp 0
crap 2
rs 10
1
<?php
2
3
declare( strict_types = 1 );
4
5
namespace ModernTimeline;
6
7
class ModernTimelineSetup {
8
9
	public static function onExtensionFunction(): void {
10
		self::doSmwCheck();
11
12
		$GLOBALS['smwgResultFormats']['moderntimeline'] = ModernTimelinePrinter::class;
13
	}
14
15
	private static function doSmwCheck(): void {
16
		if ( !defined( 'SMW_VERSION' ) ) {
17
18
			if ( PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg' ) {
19
				die( "\nThe 'Modern Timeline' extension requires 'Semantic MediaWiki' to be installed and enabled.\n" );
0 ignored issues
show
Best Practice introduced by
Using exit here is not recommended.

In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.

Loading history...
20
			}
21
22
			die(
0 ignored issues
show
Best Practice introduced by
Using exit here is not recommended.

In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.

Loading history...
23
				'<b>Error:</b> The <a href="https://professional.wiki/en/extension/modern-timeline">Modern Timeline</a> ' .
24
				'extension requires <a href="https://www.semantic-mediawiki.org/wiki/Semantic_MediaWiki">Semantic MediaWiki</a> to be ' .
25
				'installed and enabled.<br />'
26
			);
27
		}
28
	}
29
30
}
31