Conditions | 7 |
Paths | 5 |
Total Lines | 28 |
Code Lines | 15 |
Lines | 0 |
Ratio | 0 % |
Tests | 16 |
CRAP Score | 7 |
Changes | 0 |
1 | <?php |
||
18 | 3 | protected function removeInvalidChildren(LoggerInterface $logger) |
|
19 | { |
||
20 | // No HeadingContent descendants |
||
21 | // No SectioningContent descendants |
||
22 | // No "header", "footer", or "address" element descendants. |
||
|
|||
23 | 3 | foreach ($this->children as $child) { |
|
24 | 3 | if ($child instanceof HeadingContent) { |
|
25 | 1 | $logger->debug('Removing ' . $child . '. Heading Content elements not allowed as "address" element child.'); |
|
26 | 1 | $this->removeChild($child); |
|
27 | |||
28 | 1 | continue; |
|
29 | } |
||
30 | |||
31 | 3 | if ($child instanceof SectioningContent) { |
|
32 | 1 | $logger->debug('Removing ' . $child . '. Sectioning Content elements not allowed as "address" element child.'); |
|
33 | 1 | $this->removeChild($child); |
|
34 | |||
35 | 1 | continue; |
|
36 | } |
||
37 | |||
38 | 3 | if ($child instanceof Header || |
|
39 | 3 | $child instanceof Footer || |
|
40 | 3 | $child instanceof self) { |
|
41 | 1 | $logger->debug('Removing ' . $child . '. Elements "header", "footer", and "address" not allowed as "address" element child.'); |
|
42 | 3 | $this->removeChild($child); |
|
43 | } |
||
44 | } |
||
45 | 3 | } |
|
46 | } |
||
47 |
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.
The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.
This check looks for comments that seem to be mostly valid code and reports them.