Conditions | 10 |
Paths | 24 |
Total Lines | 35 |
Code Lines | 17 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
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:
If many parameters/temporary variables are present:
1 | <?php |
||
84 | public function __construct($config = self::DefaultInstanceId) |
||
85 | { |
||
86 | assert(!empty($config)); |
||
87 | assert(is_string($config) || is_array($config)); |
||
88 | $this->logger = new NullLogger; |
||
89 | |||
90 | if (is_string($config)) |
||
91 | { |
||
92 | EmbeDi::fly($config)->configure($this); |
||
93 | } |
||
94 | else |
||
95 | { |
||
96 | EmbeDi::fly()->apply($config, $this); |
||
97 | } |
||
98 | |||
99 | // Instantiate checkers if not already provided as instances |
||
100 | $checkers = []; |
||
101 | foreach($this->checkers as $checker) |
||
102 | { |
||
103 | if(!$checker instanceof CheckerInterface) |
||
104 | { |
||
105 | assert(is_string($checker) || is_array($checker)); |
||
106 | $checkers[] = EmbeDi::fly()->apply($checker); |
||
107 | } |
||
108 | } |
||
109 | $this->checkers = $checkers; |
||
110 | |||
111 | // Ensure that all aspects have sane values |
||
112 | foreach(['whitelist', 'require'] as $name) |
||
113 | { |
||
114 | foreach($this->aspects as $aspect) |
||
115 | { |
||
116 | if(empty($this->$name[$aspect]) || !is_array($this->$name[$aspect])) |
||
117 | { |
||
118 | $this->$name[$aspect] = []; |
||
119 | } |
||
165 |
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.