Page::getSubPages()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
ccs 2
cts 2
cp 1
crap 1
1
<?php
2
3
namespace SubPageList\Lister;
4
5
use Title;
6
7
/**
8
 * Represents a node in a sub page hierarchy.
9
 *
10
 * @since 1.2
11
 *
12
 * @licence GNU GPL v2+
13
 * @author Jeroen De Dauw < [email protected] >
14
 */
15
class Page {
16
17
	/**
18
	 * @var Title
19
	 */
20
	private $title;
21
22
	/**
23
	 * @var Page[]
24
	 */
25
	private $subPages = [];
26
27
	/**
28
	 * @since 1.2
29
	 *
30
	 * @param Title $title
31
	 * @param Page[] $subPages
32
	 */
33 20
	public function __construct( Title $title, array $subPages = [] ) {
34 20
		$this->title = $title;
35
36 20
		foreach ( $subPages as $subPage ) {
37 1
			$this->addSubPage( $subPage );
38
		}
39 20
	}
40
41
	/**
42
	 * @since 1.2
43
	 *
44
	 * @return Title
45
	 */
46 17
	public function getTitle() {
47 17
		return $this->title;
48
	}
49
50
	/**
51
	 * @since 1.2
52
	 *
53
	 * @return Page[]
54
	 */
55 20
	public function getSubPages() {
56 20
		return $this->subPages;
57
	}
58
59
	/**
60
	 * @since 0.1
61
	 *
62
	 * @param Page $page
63
	 */
64 13
	public function addSubPage( Page $page ) {
65 13
		$this->subPages[] = $page;
66 13
	}
67
68
}
69