Code Duplication    Length = 15-18 lines in 2 locations

src/Tokens/Elements/Caption.php 1 location

@@ 16-33 (lines=18) @@
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 removeInvalidSelf(LoggerInterface $logger)
22
    {
23
        $parent = $this->getParent();
24
        if ($parent->getType() !== Token::ELEMENT &&
25
            $parent->getName() != 'table') {
26
            $logger->debug($this . ' must be child of "table" element.');
27
28
            return true;
29
        }
30
31
        return false;
32
    }
33
}
34

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->getName() != 'figure') {
22
            $logger->debug($this . ' must be a child of a "figure" element.');
23
24
            return true;
25
        }
26
27
        return false;
28
    }
29
}
30