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

MetricThresholdCollector::collect()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 11
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 5
c 1
b 0
f 0
nc 2
nop 0
dl 0
loc 11
rs 10
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