1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace PPP\Module\DataModel; |
4
|
|
|
|
5
|
|
|
use PPP\DataModel\AbstractNode; |
6
|
|
|
|
7
|
|
|
/** |
8
|
|
|
* Representation of a request |
9
|
|
|
* |
10
|
|
|
* @licence MIT |
11
|
|
|
* @author Thomas Pellissier Tanon |
12
|
|
|
*/ |
13
|
|
|
class ModuleRequest { |
14
|
|
|
|
15
|
|
|
/** |
16
|
|
|
* @var string |
17
|
|
|
*/ |
18
|
|
|
private $languageCode; |
19
|
|
|
|
20
|
|
|
/** |
21
|
|
|
* @var AbstractNode |
22
|
|
|
*/ |
23
|
|
|
private $sentenceTree; |
24
|
|
|
|
25
|
|
|
/** |
26
|
|
|
* @var string |
27
|
|
|
*/ |
28
|
|
|
private $requestId; |
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* @var float[] |
32
|
|
|
*/ |
33
|
|
|
private $measures; |
34
|
|
|
|
35
|
|
|
/** |
36
|
|
|
* @var string[] |
37
|
|
|
*/ |
38
|
|
|
private $trace; |
39
|
|
|
|
40
|
|
|
/** |
41
|
|
|
* @param string $languageCode |
42
|
|
|
* @param AbstractNode $sentenceTree |
43
|
|
|
* @param string $requestId |
44
|
|
|
* @param float[] $measures |
45
|
|
|
* @param string[] $trace |
46
|
|
|
*/ |
47
|
6 |
|
public function __construct($languageCode, AbstractNode $sentenceTree, $requestId, array $measures = array(), array $trace = array()) { |
48
|
6 |
|
$this->languageCode = $languageCode; |
49
|
6 |
|
$this->sentenceTree = $sentenceTree; |
50
|
6 |
|
$this->requestId = $requestId; |
51
|
6 |
|
$this->measures = $measures; |
52
|
6 |
|
$this->trace = $trace; |
53
|
6 |
|
} |
54
|
|
|
|
55
|
|
|
/** |
56
|
|
|
* @return string |
57
|
|
|
*/ |
58
|
1 |
|
public function getLanguageCode() { |
59
|
1 |
|
return $this->languageCode; |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
/** |
63
|
|
|
* @return AbstractNode |
64
|
|
|
*/ |
65
|
1 |
|
public function getSentenceTree() { |
66
|
1 |
|
return $this->sentenceTree; |
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
/** |
70
|
|
|
* @return string |
71
|
|
|
*/ |
72
|
1 |
|
public function getRequestId() { |
73
|
1 |
|
return $this->requestId; |
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
/** |
77
|
|
|
* @return float[] |
78
|
|
|
*/ |
79
|
1 |
|
public function getMeasures() { |
80
|
1 |
|
return $this->measures; |
81
|
|
|
} |
82
|
|
|
|
83
|
|
|
/** |
84
|
|
|
* @return string[] |
85
|
|
|
*/ |
86
|
1 |
|
public function getTrace() { |
87
|
1 |
|
return $this->trace; |
88
|
|
|
} |
89
|
|
|
|
90
|
|
|
/** |
91
|
|
|
* Returns if $target is equals to the current request |
92
|
|
|
* |
93
|
|
|
* @param mixed $target |
94
|
|
|
* @return boolean |
95
|
|
|
*/ |
96
|
6 |
|
public function equals($target) { |
97
|
6 |
|
return $target instanceof self && |
98
|
6 |
|
$this->languageCode === $target->languageCode && |
99
|
6 |
|
$this->sentenceTree->equals($target->sentenceTree) && |
100
|
6 |
|
$this->requestId === $target->requestId && |
101
|
6 |
|
$this->measures == $target->measures; |
102
|
|
|
} |
103
|
|
|
} |
104
|
|
|
|