1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Leankoala\HealthFoundation\Check; |
4
|
|
|
|
5
|
|
|
/** |
6
|
|
|
* Class MetricAwareResult |
7
|
|
|
* |
8
|
|
|
* @package Leankoala\HealthFoundation\Check |
9
|
|
|
* |
10
|
|
|
* @author Nils Langner <[email protected]> |
11
|
|
|
* created 2021-02-26 |
12
|
|
|
*/ |
13
|
|
|
class MetricAwareResult extends Result |
14
|
|
|
{ |
15
|
|
|
const METRIC_TYPE_NUMERIC = 'time_series_numeric'; |
16
|
|
|
const METRIC_TYPE_PERCENT = 'time_series_percent'; |
17
|
|
|
|
18
|
|
|
/** |
19
|
|
|
* @var integer |
20
|
|
|
*/ |
21
|
|
|
private $metricValue; |
22
|
|
|
|
23
|
|
|
private $metricUnit; |
24
|
|
|
|
25
|
|
|
private $metricType = self::METRIC_TYPE_NUMERIC; |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* @var int |
29
|
|
|
*/ |
30
|
|
|
private $limit; |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* @var float|int |
34
|
|
|
*/ |
35
|
|
|
private $observedValue; |
|
|
|
|
36
|
|
|
|
37
|
|
|
/** |
38
|
|
|
* @var int |
39
|
|
|
*/ |
40
|
|
|
private $observedValuePrecision; |
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* @var string |
44
|
|
|
*/ |
45
|
|
|
private $observedValueUnit; |
|
|
|
|
46
|
|
|
|
47
|
|
|
/** |
48
|
|
|
* @var string |
49
|
|
|
*/ |
50
|
|
|
private $limitType; |
51
|
|
|
|
52
|
|
|
/** |
53
|
|
|
* @var string |
54
|
|
|
*/ |
55
|
|
|
private $type; |
56
|
|
|
|
57
|
|
|
public function setMetric($value, $unit, $metricType = self::METRIC_TYPE_NUMERIC) |
58
|
|
|
{ |
59
|
|
|
$this->metricValue = $value; |
60
|
|
|
$this->metricUnit = $unit; |
61
|
|
|
$this->metricType = $metricType; |
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
/** |
65
|
|
|
* @return integer |
66
|
|
|
*/ |
67
|
|
|
public function getMetricValue() |
68
|
|
|
{ |
69
|
|
|
return $this->metricValue; |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
/** |
73
|
|
|
* @return string |
74
|
|
|
*/ |
75
|
|
|
public function getMetricUnit() |
76
|
|
|
{ |
77
|
|
|
return $this->metricUnit; |
78
|
|
|
} |
79
|
|
|
|
80
|
|
|
public function getMetricType() |
81
|
|
|
{ |
82
|
|
|
return $this->metricType; |
83
|
|
|
} |
84
|
|
|
|
85
|
|
|
/** |
86
|
|
|
* Get the limit of the metric that was checked. |
87
|
|
|
* |
88
|
|
|
* This field is optional. |
89
|
|
|
* |
90
|
|
|
* @return int|null |
91
|
|
|
*/ |
92
|
|
|
public function getLimit() |
93
|
|
|
{ |
94
|
|
|
return $this->limit; |
95
|
|
|
} |
96
|
|
|
|
97
|
|
|
/** |
98
|
|
|
* Set the limit of the metric that was checked. |
99
|
|
|
* |
100
|
|
|
* @param int $limit |
101
|
|
|
*/ |
102
|
|
|
public function setLimit(int $limit) |
103
|
|
|
{ |
104
|
|
|
$this->limit = $limit; |
105
|
|
|
} |
106
|
|
|
|
107
|
|
|
/** |
108
|
|
|
* @return string |
109
|
|
|
*/ |
110
|
|
|
public function getLimitType() |
111
|
|
|
{ |
112
|
|
|
return $this->limitType; |
113
|
|
|
} |
114
|
|
|
|
115
|
|
|
/** |
116
|
|
|
* @param string $limitType |
117
|
|
|
*/ |
118
|
|
|
public function setLimitType(string $limitType) |
119
|
|
|
{ |
120
|
|
|
$this->limitType = $limitType; |
121
|
|
|
} |
122
|
|
|
|
123
|
|
|
/** |
124
|
|
|
* @return string |
125
|
|
|
*/ |
126
|
|
|
public function getType() |
127
|
|
|
{ |
128
|
|
|
return $this->type; |
129
|
|
|
} |
130
|
|
|
|
131
|
|
|
/** |
132
|
|
|
* @param string $type |
133
|
|
|
*/ |
134
|
|
|
public function setType(string $type) |
135
|
|
|
{ |
136
|
|
|
$this->type = $type; |
137
|
|
|
} |
138
|
|
|
|
139
|
|
|
/** |
140
|
|
|
* @return int |
141
|
|
|
*/ |
142
|
|
|
public function getObservedValuePrecision() |
143
|
|
|
{ |
144
|
|
|
return $this->observedValuePrecision; |
145
|
|
|
} |
146
|
|
|
|
147
|
|
|
/** |
148
|
|
|
* @param int $observedValuePrecision |
149
|
|
|
*/ |
150
|
|
|
public function setObservedValuePrecision($observedValuePrecision) |
151
|
|
|
{ |
152
|
|
|
$this->observedValuePrecision = $observedValuePrecision; |
153
|
|
|
} |
154
|
|
|
|
155
|
|
|
} |
156
|
|
|
|