The expression return self::instance could return the type null which is incompatible with the type-hinted return Startwind\Inventorio\Metrics\Memory\Memory. Consider adding an additional type-check to rule them out.
Loading history...
22
}
23
24
private function __construct()
25
{
26
}
27
28
public function addData(string $key, float $value): void
29
{
30
if (!array_key_exists($key, $this->data)) {
31
$this->data[$key] = [];
32
}
33
34
if (count($this->data[$key]) >= self::MEMORY_SIZE) {
35
array_shift($this->data[$key]);
36
}
37
38
$this->data[$key][] = $value;
39
}
40
41
public function getData(string $key): float
42
{
43
return $this->data[$key] ?? -1;
44
}
45
46
public function addDataSet(array $dataset): void
47
{
48
foreach ($dataset as $key => $value) {
49
$this->addData($key, $value);
50
}
51
}
52
53
public function getNumberOfGreaterThan(string $key, int $threshold): int
54
{
55
if (!array_key_exists($key, $this->data)) return 0;