Passed
Push — master ( 185cb1...b3870e )
by Patrick
01:50
created

Trap   F

Complexity

Total Complexity 136

Size/Duplication

Total Lines 954
Duplicated Lines 0 %

Importance

Changes 10
Bugs 2 Features 0
Metric Value
eloc 454
c 10
b 2
f 0
dl 0
loc 954
rs 2
wmc 136

How to fix   Complexity   

Complex Class

Complex classes like Trap often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes.

Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.

While breaking up the class, it is a good idea to analyze how other classes use Trap, and based on these observations, apply Extract Interface, too.

1
<?php
2
3
4
//No autoloader when running in CLI.
5
6
include (dirname(__DIR__).'/library/Trapdirector/Icinga2Api.php');
7
include (dirname(__DIR__).'/library/Trapdirector/TrapsProcess/Logging.php');
8
include (dirname(__DIR__).'/library/Trapdirector/TrapsProcess/Database.php');
9
include (dirname(__DIR__).'/library/Trapdirector/TrapsProcess/Mib.php');
10
include (dirname(__DIR__).'/library/Trapdirector/TrapsProcess/Rule.php');
11
12
include (dirname(__DIR__).'/library/Trapdirector/TrapsProcess/Trap.php');
13
14