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

Caption::doClean()   A

Complexity

Conditions 4
Paths 3

Size

Total Lines 14
Code Lines 8

Duplication

Lines 14
Ratio 100 %

Code Coverage

Tests 0
CRAP Score 20

Importance

Changes 1
Bugs 1 Features 1
Metric Value
c 1
b 1
f 1
dl 14
loc 14
ccs 0
cts 12
cp 0
rs 9.2
cc 4
eloc 8
nc 3
nop 1
crap 20
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 Groundskeeper\Tokens\Token;
9
use Psr\Log\LoggerInterface;
10
11
/**
12
 * "caption" element
13
 *
14
 * https://html.spec.whatwg.org/multipage/semantics.html#the-caption-element
15
 */
16 View Code Duplication
class Caption 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...
17
{
18
    /**
19
     * @todo Caption must be *first* child of table.
20
     */
21
    protected function doClean(LoggerInterface $logger)
22
    {
23
        if ($this->configuration->get('clean-strategy') != Configuration::CLEAN_STRATEGY_LENIENT) {
24
            $parent = $this->getParent();
25
            if ($parent->getType() !== Token::ELEMENT &&
26
                $parent->getName() != 'table') {
27
                $logger->debug('Element "caption" must be child of "table" element.');
28
29
                return false;
30
            }
31
        }
32
33
        return true;
34
    }
35
}
36