Conditions | 10 |
Paths | 3 |
Total Lines | 18 |
Code Lines | 13 |
Lines | 0 |
Ratio | 0 % |
Tests | 15 |
CRAP Score | 10 |
Changes | 2 | ||
Bugs | 1 | Features | 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 |
||
23 | 5 | protected function removeInvalidChildren(LoggerInterface $logger) |
|
24 | { |
||
25 | 5 | foreach ($this->children as $child) { |
|
26 | 5 | if ($child instanceof NonParticipating || |
|
27 | 5 | $child instanceof Caption || |
|
28 | 5 | $child instanceof Colgroup || |
|
29 | 5 | $child instanceof Thead || |
|
30 | 5 | $child instanceof Tbody || |
|
31 | 5 | $child instanceof Tr || |
|
32 | 4 | $child instanceof Tfoot || |
|
33 | 5 | $child instanceof ScriptSupporting) { |
|
34 | 5 | continue; |
|
35 | } |
||
36 | |||
37 | 1 | $logger->debug('Removing ' . $child . '. Only "caption", "colgroup", "thead", "tbody", "tr", "tfoot", and script supporting elements allowed as children of "table" element.'); |
|
38 | 1 | $this->removeChild($child); |
|
39 | 5 | } |
|
40 | 5 | } |
|
41 | } |
||
42 |