Completed
Push — master ( c81f6c...1650a0 )
by mw
07:33
created

OutlineItem   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 51
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 84.62%

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 0
dl 0
loc 51
ccs 11
cts 13
cp 0.8462
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A addFieldValue() 0 7 2
A getFieldValues() 0 8 2
1
<?php
2
3
namespace SRF\Outline;
4
5
/**
6
 * Represents a single item, or page, in the outline - contains both the
7
 * SMWResultArray and an array of some of its values, for easier aggregation
8
 *
9
 * @license GNU GPL v2+
10
 * @since 3.1
11
 */
12
class OutlineItem {
13
14
	/**
15
	 * @var [type]
16
	 */
17
	public $row;
18
19
	/**
20
	 * @var []
21
	 */
22
	private $vals;
23
24
	/**
25
	 * @since 3.1
26
	 *
27
	 * @param $row
28
	 */
29 4
	public function __construct( $row ) {
30 4
		$this->row = $row;
31 4
		$this->vals = [];
32 4
	}
33
34
	/**
35
	 * @since 3.1
36
	 *
37
	 * @param $name
38
	 * @param $value
39
	 */
40 2
	public function addFieldValue( $key, $value ) {
41 2
		if ( array_key_exists( $key, $this->vals ) ) {
42
			$this->vals[$key][] = $value;
43
		} else {
44 2
			$this->vals[$key] = [ $value ];
45
		}
46 2
	}
47
48
	/**
49
	 * @since 3.1
50
	 *
51
	 * @param $row
52
	 */
53 2
	public function getFieldValues( $key ) {
54
55 2
		if ( array_key_exists( $key, $this->vals ) ) {
56 2
			return $this->vals[$key];
57
		}
58
59
		return [ wfMessage( 'srf_outline_novalue' )->text() ];
60
	}
61
62
}
63