Code Duplication    Length = 15-18 lines in 5 locations

src/Tokens/Elements/Figcaption.php 1 location

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

src/Tokens/Elements/Caption.php 1 location

@@ 14-31 (lines=18) @@
11
 *
12
 * https://html.spec.whatwg.org/multipage/semantics.html#the-caption-element
13
 */
14
class Caption extends OpenElement implements FlowContent
15
{
16
    /**
17
     * @todo Caption must be *first* child of table.
18
     */
19
    protected function removeInvalidSelf(LoggerInterface $logger)
20
    {
21
        $parent = $this->getParent();
22
        if ($parent !== null &&
23
            !($parent instanceof Table)) {
24
            $logger->debug('Removing ' . $this . '. Must be child of "table" element.');
25
26
            return true;
27
        }
28
29
        return false;
30
    }
31
}
32

src/Tokens/Elements/Dd.php 1 location

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

src/Tokens/Elements/Rp.php 1 location

@@ 13-27 (lines=15) @@
10
 *
11
 * https://html.spec.whatwg.org/multipage/semantics.html#the-rp-element
12
 */
13
class Rp extends OpenElement
14
{
15
    protected function removeInvalidSelf(LoggerInterface $logger)
16
    {
17
        // Must be child of "ruby" element.
18
        $parent = $this->getParent();
19
        if ($parent !== null && !$parent instanceof Ruby) {
20
            $logger->debug('Removing ' . $this . '. Must be a child of a "ruby" element.');
21
22
            return true;
23
        }
24
25
        return false;
26
    }
27
}
28

src/Tokens/Elements/Rt.php 1 location

@@ 13-27 (lines=15) @@
10
 *
11
 * https://html.spec.whatwg.org/multipage/semantics.html#the-rt-element
12
 */
13
class Rt extends OpenElement
14
{
15
    protected function removeInvalidSelf(LoggerInterface $logger)
16
    {
17
        // Must be child of "ruby" element.
18
        $parent = $this->getParent();
19
        if ($parent !== null && !$parent instanceof Ruby) {
20
            $logger->debug('Removing ' . $this . '. Must be a child of a "ruby" element.');
21
22
            return true;
23
        }
24
25
        return false;
26
    }
27
}
28