Completed
Push — 2.0 ( b1f1bc )
by Vitaly
08:30
created

Module   C

Complexity

Total Complexity 55

Size/Duplication

Total Lines 508
Duplicated Lines 0 %

Coupling/Cohesion

Components 3
Dependencies 5

Test Coverage

Coverage 95.68%

Importance

Changes 40
Bugs 13 Features 14
Metric Value
wmc 55
c 40
b 13
f 14
lcom 3
cbo 5
dl 0
loc 508
ccs 155
cts 162
cp 0.9568
rs 6.8

1 Method

Rating   Name   Duplication   Size   Complexity  
A init() 0 4 1

How to fix   Complexity   

Complex Class

Complex classes like Module 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. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.

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 Module, and based on these observations, apply Extract Interface, too.

1
<?php
2
namespace samsonphp\core;
3
4
/**
5
 * Module
6
 *
7
 * @author Vitaly Iegorov <[email protected]>
8
 */
9
abstract class Module
10
{
11
    /**
12
     * Module configuration stage
13
     * @param ContainerInterface $container
14
     */
15
    abstract public function configure(ContainerInterface $container);
16
17
    /**
18
     * Module preparation stage
19
     */
20
    public function prepare()
21
    {
22
23
    }
24
25
    /**
26
     * Module initialization stage
27
     */
28
    public function init()
29
    {
30
31
    }
32
}
33