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 addDataSet(array $dataset): void
42
{
43
foreach ($dataset as $key => $value) {
44
$this->addData($key, $value);
45
}
46
}
47
48
public function getNumberOfGreaterThan(string $key, int $threshold): int
49
{
50
if (!array_key_exists($key, $this->data)) return 0;