PropertyRegistry::register()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 37

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 26
CRAP Score 3

Importance

Changes 0
Metric Value
dl 0
loc 37
ccs 26
cts 26
cp 1
rs 9.328
c 0
b 0
f 0
cc 3
nc 3
nop 1
crap 3
1
<?php
2
3
namespace SBL;
4
5
use SMW\DIProperty;
6
7
/**
8
 * @license GNU GPL v2+
9
 * @since 1.0
10
 *
11
 * @author mwjames
12
 */
13
class PropertyRegistry {
14
15
	const SBL_PARENTPAGE = '__sbl_parentpage';
16
17
	/**
18
	 * @since 1.0
19
	 *
20
	 * @return boolean
21
	 */
22 1
	public function register( $propertyRegistry ) {
23
24
		$propertyDefinitions = [
25
26 1
			self::SBL_PARENTPAGE => [
27 1
				'label' => SBL_PROP_PARENTPAGE,
28 1
				'type'  => '_wpg',
29 1
				'alias' => 'sbl-property-alias-parentpage',
30
				'visbility' => true
31 1
			]
32 1
		];
33
34 1
		foreach ( $propertyDefinitions as $propertyId => $definition ) {
35
36 1
			$propertyRegistry->registerProperty(
37 1
				$propertyId,
38 1
				$definition['type'],
39 1
				$definition['label'],
40 1
				$definition['visbility']
41 1
			);
42
43 1
			$propertyRegistry->registerPropertyAlias(
44 1
				$propertyId,
45 1
				wfMessage( $definition['alias'] )->text()
46 1
			);
47
48
			// 2.4+
49 1
			if ( method_exists( $propertyRegistry, 'registerPropertyAliasByMsgKey' ) ) {
50 1
				$propertyRegistry->registerPropertyAliasByMsgKey(
51 1
					$propertyId,
52 1
					$definition['alias']
53 1
				);
54 1
			}
55 1
		}
56
57 1
		return true;
58
	}
59
60
}
61