Completed
Push — master ( e0ac7a...8eddfc )
by Kevin
03:21
created

Header::doClean()   B

Complexity

Conditions 5
Paths 3

Size

Total Lines 17
Code Lines 11

Duplication

Lines 17
Ratio 100 %

Code Coverage

Tests 10
CRAP Score 5.1158

Importance

Changes 3
Bugs 1 Features 3
Metric Value
c 3
b 1
f 3
dl 17
loc 17
ccs 10
cts 12
cp 0.8333
rs 8.8571
cc 5
eloc 11
nc 3
nop 1
crap 5.1158
1
<?php
2
3
namespace Groundskeeper\Tokens\Elements;
4
5
use Groundskeeper\Configuration;
6
use Groundskeeper\Tokens\ElementTypes\FlowContent;
7
use Groundskeeper\Tokens\ElementTypes\OpenElement;
8
use Psr\Log\LoggerInterface;
9
10
/**
11
 * "header" element
12
 */
13 View Code Duplication
class Header extends OpenElement implements FlowContent
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

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.

Loading history...
14
{
15 1
    protected function doClean(LoggerInterface $logger)
16
    {
17 1
        if ($this->configuration->get('clean-strategy') != Configuration::CLEAN_STRATEGY_LENIENT) {
18 1
            $footer = new Footer($this->configuration, 'footer');
19 1
            $header = new self($this->configuration, 'header');
20 1
            $main = new Main($this->configuration, 'main');
21 1
            if ($this->hasAncestor($footer) ||
22
                $this->hasAncestor($header) ||
23 1
                $this->hasAncestor($main)) {
24 1
                $logger->debug('Removing ' . $this . '. Element "header" should not be a descendant of "footer", "header", or "main" elements.');
25
26 1
                return false;
27
            }
28
        }
29
30 1
        return true;
31
    }
32
}
33