ModuleResponse::equals()   A
last analyzed

Complexity

Conditions 4
Paths 4

Size

Total Lines 6
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 4

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 6
ccs 5
cts 5
cp 1
rs 9.2
cc 4
eloc 5
nc 4
nop 1
crap 4
1
<?php
2
3
namespace PPP\Module\DataModel;
4
5
use PPP\DataModel\AbstractNode;
6
7
/**
8
 * Representation of a response
9
 *
10
 * @licence MIT
11
 * @author Thomas Pellissier Tanon
12
 */
13
class ModuleResponse {
14
15
	/**
16
	 * @var string
17
	 */
18
	private $languageCode;
19
20
	/**
21
	 * @var AbstractNode
22
	 */
23
	private $sentenceTree;
24
25
	/**
26
	 * @var float[]
27
	 */
28
	private $measures;
29
30
	/**
31
	 * @var string[]
32
	 */
33
	private $trace;
34
35
	/**
36
	 * @param string $languageCode
37
	 * @param AbstractNode $sentenceTree
38
	 * @param float[] $measures
39
	 * @param string[] $trace
40
	 */
41 5
	public function __construct($languageCode, AbstractNode $sentenceTree, array $measures = array(), array $trace = array()) {
42 5
		$this->languageCode = $languageCode;
43 5
		$this->sentenceTree = $sentenceTree;
44 5
		$this->measures = $measures;
45 5
		$this->trace = $trace;
46 5
	}
47
48
	/**
49
	 * @return string
50
	 */
51 1
	public function getLanguageCode() {
52 1
		return $this->languageCode;
53
	}
54
55
	/**
56
	 * @return AbstractNode
57
	 */
58 1
	public function getSentenceTree() {
59 1
		return $this->sentenceTree;
60
	}
61
62
	/**
63
	 * @return float[]
64
	 */
65 1
	public function getMeasures() {
66 1
		return $this->measures;
67
	}
68
69
	/**
70
	 * @return string[]
71
	 */
72 1
	public function getTrace() {
73 1
		return $this->trace;
74
	}
75
76
	/**
77
	 * Returns if $target is equals to the current response
78
	 *
79
	 * @param mixed $target
80
	 * @return boolean
81
	 */
82 5
	public function equals($target) {
83 5
		return $target instanceof self &&
84 5
			$this->languageCode === $target->languageCode &&
85 5
			$this->sentenceTree->equals($target->sentenceTree) &&
86 5
			$this->measures == $target->measures;
87
	}
88
}
89