Passed
Push — master ( 1e1210...91799c )
by Nils
02:53
created

WebProsMonitoringCollector   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 14
c 1
b 0
f 0
dl 0
loc 34
rs 10
wmc 5

2 Methods

Rating   Name   Duplication   Size   Complexity  
A collect() 0 17 4
A getIdentifier() 0 3 1
1
<?php
2
3
namespace Startwind\Inventorio\Collector\Application\Monitoring;
4
5
use Startwind\Inventorio\Collector\Collector;
6
7
class WebProsMonitoringCollector implements Collector
8
{
9
    protected const INI_FILE = '/etc/agent360-token.ini';
10
11
    protected const COLLECTION_IDENTIFIER = 'WebProsMonitoring';
12
13
    /**
14
     * @inheritDoc
15
     */
16
    public function getIdentifier(): string
17
    {
18
        return self::COLLECTION_IDENTIFIER;
19
    }
20
21
    /**
22
     * @inheritDoc
23
     */
24
    public function collect(): array
25
    {
26
        if (!file_exists(self::INI_FILE)) return [];
27
28
        $config = file(self::INI_FILE);
29
30
        $configArray = [];
31
32
        foreach ($config as $line) {
33
            if (str_starts_with('[', $line)) continue;
34
            $element = explode('=', $line);
35
            $configArray[$element[0]] = $element[1];
36
        }
37
38
        return [
39
            'server' => $configArray['server'],
40
            'user' => $configArray['user']
41
        ];
42
    }
43
}
44