Code Duplication    Length = 17-20 lines in 5 locations

src/Tokens/Elements/Figcaption.php 1 location

@@ 16-32 (lines=17) @@
13
 *
14
 * https://html.spec.whatwg.org/multipage/semantics.html#the-figcaption-element
15
 */
16
class Figcaption extends OpenElement implements FlowContent, SectioningRoot
17
{
18
    protected function doClean(LoggerInterface $logger)
19
    {
20
        // Must be child of "figure" element.
21
        $parent = $this->getParent();
22
        if ($this->configuration->get('clean-strategy') != Configuration::CLEAN_STRATEGY_LENIENT &&
23
            $parent !== null &&
24
            $parent->getName() != 'figure') {
25
            $logger->debug('Element "figcaption" must be a child of a "figure" element.');
26
27
            return false;
28
        }
29
30
        return true;
31
    }
32
}
33

src/Tokens/Elements/Caption.php 1 location

@@ 16-35 (lines=20) @@
13
 *
14
 * https://html.spec.whatwg.org/multipage/semantics.html#the-caption-element
15
 */
16
class Caption extends OpenElement implements FlowContent
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

src/Tokens/Elements/Dd.php 1 location

@@ 14-30 (lines=17) @@
11
 *
12
 * https://html.spec.whatwg.org/multipage/semantics.html#the-dd-element
13
 */
14
class Dd extends OpenElement
15
{
16
    protected function doClean(LoggerInterface $logger)
17
    {
18
        // Must be child of "dl" element.
19
        $parent = $this->getParent();
20
        if ($this->configuration->get('clean-strategy') != Configuration::CLEAN_STRATEGY_LENIENT &&
21
            $parent !== null &&
22
            $parent->getName() != 'dl') {
23
            $logger->debug('Element "dt" must be a child of a "dl" element.');
24
25
            return false;
26
        }
27
28
        return true;
29
    }
30
}
31

src/Tokens/Elements/Rp.php 1 location

@@ 14-30 (lines=17) @@
11
 *
12
 * https://html.spec.whatwg.org/multipage/semantics.html#the-rp-element
13
 */
14
class Rp extends OpenElement
15
{
16
    protected function doClean(LoggerInterface $logger)
17
    {
18
        // Must be child of "ruby" element.
19
        $parent = $this->getParent();
20
        if ($this->configuration->get('clean-strategy') != Configuration::CLEAN_STRATEGY_LENIENT &&
21
            $parent !== null &&
22
            $parent->getName() != 'ruby') {
23
            $logger->debug('Element "rp" must be a child of a "ruby" element.');
24
25
            return false;
26
        }
27
28
        return true;
29
    }
30
}
31

src/Tokens/Elements/Rt.php 1 location

@@ 14-30 (lines=17) @@
11
 *
12
 * https://html.spec.whatwg.org/multipage/semantics.html#the-rt-element
13
 */
14
class Rt extends OpenElement
15
{
16
    protected function doClean(LoggerInterface $logger)
17
    {
18
        // Must be child of "ruby" element.
19
        $parent = $this->getParent();
20
        if ($this->configuration->get('clean-strategy') != Configuration::CLEAN_STRATEGY_LENIENT &&
21
            $parent !== null &&
22
            $parent->getName() != 'ruby') {
23
            $logger->debug('Element "rt" must be a child of a "ruby" element.');
24
25
            return false;
26
        }
27
28
        return true;
29
    }
30
}
31