Conditions | 9 |
Paths | 3 |
Total Lines | 36 |
Code Lines | 19 |
Lines | 36 |
Ratio | 100 % |
Tests | 21 |
CRAP Score | 9 |
Changes | 1 | ||
Bugs | 0 | Features | 1 |
1 | <?php |
||
18 | 4 | protected function doClean(LoggerInterface $logger) |
|
19 | { |
||
20 | 4 | if ($this->configuration->get('clean-strategy') != Configuration::CLEAN_STRATEGY_LENIENT) { |
|
21 | // "table" must be parent. |
||
22 | 4 | $parent = $this->getParent(); |
|
23 | 4 | if ($parent !== null && $parent->getName() != 'table') { |
|
24 | 1 | $logger->debug('Element "tfoot" must be a child of the "table" element.'); |
|
25 | |||
26 | 1 | return false; |
|
27 | } |
||
28 | |||
29 | // Children can be "tr" and script supporting elements. |
||
30 | 3 | foreach ($this->children as $child) { |
|
31 | 3 | if ($child->getType() == Token::COMMENT) { |
|
32 | 1 | continue; |
|
33 | } |
||
34 | |||
35 | 3 | if ($child->getType() !== Token::ELEMENT) { |
|
36 | 1 | $logger->debug('Removing ' . $child . '. Only elements allowed as children of "tfoot" element.'); |
|
37 | 1 | $this->removeChild($child); |
|
38 | |||
39 | 1 | continue; |
|
40 | } |
||
41 | |||
42 | 2 | if ($child->getName() == 'tr' || |
|
43 | 2 | $child instanceof ScriptSupporting) { |
|
44 | 1 | continue; |
|
45 | } |
||
46 | |||
47 | 1 | $logger->debug('Removing ' . $child . '. Only "tr" and script supporting elements allowed as children of "tfoot" element.'); |
|
48 | 1 | $this->removeChild($child); |
|
49 | 3 | } |
|
50 | 3 | } |
|
51 | |||
52 | 4 | return true; |
|
53 | } |
||
54 | } |
||
55 |
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.