Passed
Push — master ( af36fa...585457 )
by Nils
02:48
created

MetricThresholdCollector   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 9
c 1
b 0
f 0
dl 0
loc 19
rs 10
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A collect() 0 11 2
1
<?php
2
3
namespace Startwind\Inventorio\Collector\Metrics;
4
5
use Startwind\Inventorio\Collector\BasicCollector;
6
use Startwind\Inventorio\Metrics\Memory\Memory;
7
8
class MetricThresholdCollector extends BasicCollector
9
{
10
    protected string $identifier = 'MetricsThreshold';
11
12
    private array $thresholds = [
13
        'cpu.usage' => 80
14
    ];
15
16
    public function collect(): array
17
    {
18
        $memory = Memory::getInstance();
19
20
        $result = [];
21
22
        foreach ($this->thresholds as $metric => $threshold) {
23
            $result[$metric] = $memory->getNumberOfGreaterThan($metric, $threshold);
24
        }
25
26
        return $result;
27
    }
28
}
29