Address::removeInvalidChildren()   C
last analyzed

Complexity

Conditions 7
Paths 5

Size

Total Lines 28
Code Lines 15

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 16
CRAP Score 7

Importance

Changes 0
Metric Value
dl 0
loc 28
ccs 16
cts 16
cp 1
rs 6.7272
c 0
b 0
f 0
cc 7
eloc 15
nc 5
nop 1
crap 7
1
<?php
2
3
namespace Groundskeeper\Tokens\Elements;
4
5
use Groundskeeper\Tokens\ElementTypes\FlowContent;
6
use Groundskeeper\Tokens\ElementTypes\HeadingContent;
7
use Groundskeeper\Tokens\ElementTypes\OpenElement;
8
use Groundskeeper\Tokens\ElementTypes\SectioningContent;
9
use Psr\Log\LoggerInterface;
10
11
/**
12
 * "address" element
13
 *
14
 * https://html.spec.whatwg.org/multipage/semantics.html#the-address-element
15
 */
16
class Address extends OpenElement implements FlowContent
17
{
18 3
    protected function removeInvalidChildren(LoggerInterface $logger)
19
    {
20
        // No HeadingContent descendants
21
        // No SectioningContent descendants
22
        // No "header", "footer", or "address" element descendants.
0 ignored issues
show
Unused Code Comprehensibility introduced by
36% of this comment could be valid code. Did you maybe forget this after debugging?

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.

Loading history...
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