Completed
Push — master ( 946aec...bc2207 )
by mw
03:21
created

PropertyRegistry::register()   B

Complexity

Conditions 2
Paths 2

Size

Total Lines 58

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 21
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 58
rs 8.9163
c 0
b 0
f 0
ccs 21
cts 21
cp 1
cc 2
nc 2
nop 1
crap 2

How to fix   Long Method   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
2
3
namespace SMW\ApprovedRevs;
4
5
/**
6
 * @license GNU GPL v2+
7
 * @since 1.0
8
 *
9
 * @author mwjames
10
 */
11
class PropertyRegistry {
12
13
	const SAR_PROP_APPROVED_REV = '__sar_approved_rev';
14
	const SAR_PROP_APPROVED_BY = '__sar_approved_by';
15
	const SAR_PROP_APPROVED_DATE = '__sar_approved_date';
16
	const SAR_PROP_APPROVED_STATUS = '__sar_approved_status';
17
18
	/**
19
	 * @since 1.0
20
	 *
21
	 * @param PropertyRegistry $propertyRegistry
22
	 */
23 1
	public function register( $propertyRegistry ) {
24
25
		$defs = [
26 1
			self::SAR_PROP_APPROVED_REV => [
27
				'label' => 'Approved revision',
28
				'type'  => '_num',
29
				'alias' => 'semantic-approvedrevs-property-approved-rev',
30
				'desc' => 'semantic-approvedrevs-property-approved-rev-desc',
31
				'visbility' => false
32
			],
33 1
			self::SAR_PROP_APPROVED_BY => [
34
				'label' => 'Approved by',
35
				'type'  => '_wpg',
36
				'alias' => 'semantic-approvedrevs-property-approved-by',
37
				'desc' => 'semantic-approvedrevs-property-approved-by-desc',
38
				'visbility' => false
39
			],
40 1
			self::SAR_PROP_APPROVED_DATE => [
41
				'label' => 'Approved date',
42
				'type'  => '_dat',
43
				'alias' => 'semantic-approvedrevs-property-approved-date',
44
				'desc' => 'semantic-approvedrevs-property-approved-date-desc',
45
				'visbility' => false
46
			],
47 1
			self::SAR_PROP_APPROVED_STATUS => [
48
				'label' => 'Approval status',
49
				'type'  => '_txt',
50
				'alias' => 'semantic-approvedrevs-property-approved-status',
51
				'desc' => 'semantic-approvedrevs-property-approved-status-desc',
52
				'visbility' => false
53
			]
54
		];
55
56 1
		foreach ( $defs as $key => $definition ) {
57
58 1
			$propertyRegistry->registerProperty(
0 ignored issues
show
Bug introduced by
The method registerProperty() does not exist on SMW\ApprovedRevs\PropertyRegistry. Did you maybe mean register()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
59 1
				$key,
60 1
				$definition['type'],
61 1
				$definition['label'],
62 1
				$definition['visbility']
63
			);
64
65 1
			$propertyRegistry->registerPropertyAlias(
0 ignored issues
show
Bug introduced by
The method registerPropertyAlias() does not exist on SMW\ApprovedRevs\PropertyRegistry. Did you maybe mean register()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
66 1
				$key,
67 1
				wfMessage( $definition['alias'] )->text()
68
			);
69
70 1
			$propertyRegistry->registerPropertyAliasByMsgKey(
0 ignored issues
show
Bug introduced by
The method registerPropertyAliasByMsgKey() does not exist on SMW\ApprovedRevs\PropertyRegistry. Did you maybe mean register()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
71 1
				$key,
72 1
				$definition['alias']
73
			);
74
75 1
			$propertyRegistry->registerPropertyDescriptionMsgKeyById(
0 ignored issues
show
Bug introduced by
The method registerPropertyDescriptionMsgKeyById() does not exist on SMW\ApprovedRevs\PropertyRegistry. Did you maybe mean register()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
76 1
				$key,
77 1
				$definition['desc']
78
			);
79
		}
80 1
	}
81
82
}
83