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

WebProsMonitoringCollector::collect()   A

Complexity

Conditions 4
Paths 4

Size

Total Lines 17
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

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