Passed
Push — master ( f1175e...1a1d56 )
by Nils
03:05
created

CollectorCommand::initCollectors()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 56
Code Lines 30

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 30
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 56
rs 9.44

How to fix   Long Method   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
2
3
namespace Startwind\Inventorio\Command;
4
5
use Startwind\Inventorio\Collector\Application\Monitoring\WebProsMonitoringCollector;
6
use Startwind\Inventorio\Collector\Application\ProgrammingLanguage\PhpCollector;
7
use Startwind\Inventorio\Collector\Application\WebServer\Apache\ApacheConfigurationCollector;
8
use Startwind\Inventorio\Collector\Application\WebServer\Apache\ApacheServerNameCollector;
9
use Startwind\Inventorio\Collector\Collector;
10
use Startwind\Inventorio\Collector\Hosting\HostingCompany\ASNCollector;
11
use Startwind\Inventorio\Collector\Inventorio\CommandCollector;
12
use Startwind\Inventorio\Collector\Inventorio\InventorioCollector;
13
use Startwind\Inventorio\Collector\Metrics\MetricThresholdCollector;
14
use Startwind\Inventorio\Collector\OperatingSystem\OperatingSystemCollector;
15
use Startwind\Inventorio\Collector\Package\Brew\BrewPackageCollector;
16
use Startwind\Inventorio\Collector\Package\Dpkg\DpkgPackageCollector;
17
use Startwind\Inventorio\Collector\System\Cron\CronCollector;
18
use Startwind\Inventorio\Collector\System\General\ConfigurationCollector;
19
use Startwind\Inventorio\Collector\System\General\DiskCollector;
20
use Startwind\Inventorio\Collector\System\General\IpCollector;
21
use Startwind\Inventorio\Collector\System\General\UptimeCollector;
22
use Startwind\Inventorio\Collector\System\Logs\LogrotateCollector;
23
use Startwind\Inventorio\Collector\System\Ports\PortsCollector;
24
use Startwind\Inventorio\Collector\System\Security\AuthorizedKeysCollector;
25
use Startwind\Inventorio\Collector\System\Security\GeneralSecurityCollector;
26
use Startwind\Inventorio\Collector\System\Service\SystemDCollector;
27
use Startwind\Inventorio\Collector\System\UserCollector;
28
use Startwind\Inventorio\Collector\Website\HeaderCollector;
29
use Startwind\Inventorio\Collector\Website\ResponseCollector;
30
use Startwind\Inventorio\Collector\Website\WordPress\DatabaseCredentialCollector;
31
use Startwind\Inventorio\Collector\Website\WordPress\WordPressCollector;
32
33
abstract class CollectorCommand extends InventorioCommand
34
{
35
    /**
36
     * @var Collector[]
37
     */
38
    protected array $collectors = [];
39
40
41
    /**
42
     * Initialize all collectors.
43
     *
44
     * @todo use a config file to add collectors
45
     */
46
    protected function initCollectors(): void
47
    {
48
        // Inventorio
49
        $this->collectors[] = new InventorioCollector(
50
            $this->isRemoteEnabled(),
51
            $this->areLogfilesEnabled(),
52
            $this->isCollectEnabled(),
53
            $this->config
54
        );
55
56
        $this->collectors[] = new CommandCollector($this->config);
57
        // $this->collectors[] = new RandomCollector();
58
59
        // General
60
        $this->collectors[] = new OperatingSystemCollector();
61
62
        // Hosting
63
        $this->collectors[] = new ASNCollector();
64
65
        // Metrics
66
        $this->collectors[] = new MetricThresholdCollector();
67
68
        // System / General
69
        $this->collectors[] = new IpCollector();
70
        $this->collectors[] = new UptimeCollector();
71
        $this->collectors[] = new PortsCollector();
72
        $this->collectors[] = new ConfigurationCollector();
73
        $this->collectors[] = new CronCollector();
74
        $this->collectors[] = new UserCollector();
75
        $this->collectors[] = new LogrotateCollector();
76
        $this->collectors[] = new DiskCollector();
77
78
        // System / Services
79
        $this->collectors[] = new SystemDCollector();
80
81
        // System / Security
82
        $this->collectors[] = new GeneralSecurityCollector();
83
        $this->collectors[] = new AuthorizedKeysCollector();
84
85
        // Package Managers
86
        $this->collectors[] = new BrewPackageCollector();
87
        $this->collectors[] = new DpkgPackageCollector();
88
89
        // Application / Programming Language
90
        $this->collectors[] = new PhpCollector();
91
        $this->collectors[] = new WebProsMonitoringCollector();
92
93
        // Application / WebServer
94
        $this->collectors[] = new ApacheServerNameCollector();
95
        $this->collectors[] = new ApacheConfigurationCollector();
96
        $this->collectors[] = new HeaderCollector();
97
98
        // INVENTORY AWARE
99
        $this->collectors[] = new WordPressCollector();
100
        $this->collectors[] = new DatabaseCredentialCollector();
101
        $this->collectors[] = new ResponseCollector();
102
    }
103
}
104