Completed
Pull Request — master (#507)
by
unknown
14:08
created

GraphNode   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 46
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 6
lcom 1
cbo 0
dl 0
loc 46
ccs 17
cts 17
cp 1
rs 10
c 0
b 0
f 0

6 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A getID() 0 3 1
A addParentNode() 0 6 1
A getParentNode() 0 3 1
A setLabel() 0 3 1
A getLabel() 0 3 1
1
<?php
2
3
namespace SRF\Graph;
4
5
class GraphNode {
6
	private $id;
7
	private $parent = [];
8
	private $label;
9
10
	/**
11
	 * @var string $id : Node ID including namespace
12
	 */
13 3
	public function __construct( $id ) {
14 3
		$this->id = $id;
15 3
	}
16
17 1
	public function getID() {
18 1
		return $this->id;
19
	}
20
21
	/**
22
	 * @var string $predicate : the "predicate" linking an object to a subject
23
	 * @var srting $object : the object, linked to this node
24
	 */
25 1
	public function addParentNode( $predicate, $object ) {
26 1
		$this->parent[] = [
27 1
			"predicate" => $predicate,
28 1
			"object"    => $object
29
		];
30 1
	}
31
32
	/**
33
	 * @return array Of parent nodes
34
	 */
35 1
	public function getParentNode() {
36 1
		return $this->parent;
37
	}
38
39
	/**
40
	 * @param string $label : a label, e.g. Display Title, used instead of $id.
41
	 */
42 1
	public function setLabel($label){
43 1
		$this->label = $label;
44 1
	}
45
46 1
	public function getLabel() {
47 1
		return $this->label;
48
	}
49
50
}
51