Completed
Push — master ( fef96a...9f8b44 )
by Kevin
03:02
created

Address::doClean()   D

Complexity

Conditions 9
Paths 5

Size

Total Lines 33
Code Lines 16

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 90

Importance

Changes 2
Bugs 1 Features 2
Metric Value
c 2
b 1
f 2
dl 0
loc 33
ccs 0
cts 24
cp 0
rs 4.909
cc 9
eloc 16
nc 5
nop 1
crap 90
1
<?php
2
3
namespace Groundskeeper\Tokens\Elements;
4
5
use Groundskeeper\Configuration;
6
use Groundskeeper\Tokens\ElementTypes\FlowContent;
7
use Groundskeeper\Tokens\ElementTypes\HeadingContent;
8
use Groundskeeper\Tokens\ElementTypes\OpenElement;
9
use Groundskeeper\Tokens\ElementTypes\SectioningContent;
10
use Groundskeeper\Tokens\Token;
11
use Psr\Log\LoggerInterface;
12
13
/**
14
 * "address" element
15
 *
16
 * https://html.spec.whatwg.org/multipage/semantics.html#the-address-element
17
 */
18
class Address extends OpenElement implements FlowContent
19
{
20
    protected function doClean(LoggerInterface $logger)
21
    {
22
        if ($this->configuration->get('clean-strategy') != Configuration::CLEAN_STRATEGY_LENIENT) {
23
            // No HeadingContent descendants
24
            // No SectioningContent descendants
25
            // 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...
26
            foreach ($this->children as $child) {
27
                if ($child instanceof HeadingContent) {
28
                    $logger->debug('Heading Content elements not allowed as "address" element child.');
29
30
                    return false;
31
                }
32
33
                if ($child instanceof SectioningContent) {
34
                    $logger->debug('Sectioning Content elements not allowed as "address" element child.');
35
36
                    return false;
37
                }
38
39
                if ($child->getType() == Token::ELEMENT) {
40
                    if ($child->getName() == 'header' ||
41
                        $child->getName() == 'footer' ||
42
                        $child->getName() == 'address') {
43
                        $logger->debug('Elements "header", "footer", and "address" not allowed as "address" element child.');
44
45
                        return false;
46
                    }
47
                }
48
            }
49
        }
50
51
        return true;
52
    }
53
}
54