Code Duplication    Length = 10-19 lines in 5 locations

src/Tokens/Elements/Time.php 1 location

@@ 32-50 (lines=19) @@
29
        );
30
    }
31
32
    protected function removeInvalidChildren(LoggerInterface $logger)
33
    {
34
        // If attribute "datetime" is not present, then only TEXT type
35
        // children allowed.
36
        if (!$this->hasAttribute('datetime')) {
37
            foreach ($this->children as $child) {
38
                if ($child instanceof NonParticipating) {
39
                    continue;
40
                }
41
42
                if (!$child instanceof Text) {
43
                    $logger->debug('Removing ' . $child . '. Element "time" without "datetime" attribute may only contain TEXT.');
44
                    $this->removeChild($child);
45
46
                    continue;
47
                }
48
            }
49
        }
50
    }
51
}
52

src/Tokens/Elements/Title.php 1 location

@@ 16-29 (lines=14) @@
13
 */
14
class Title extends OpenElement implements MetadataContent
15
{
16
    protected function removeInvalidChildren(LoggerInterface $logger)
17
    {
18
        // TITLE must contain only non-whitespace text or comments.
19
        foreach ($this->children as $child) {
20
            if ($child instanceof NonParticipating) {
21
                continue;
22
            }
23
24
            if (!$child instanceof Text) {
25
                $logger->debug('Removing ' . $child . '. Only text allowed inside TITLE.');
26
                $this->removeChild($child);
27
            }
28
        }
29
    }
30
}
31

src/Tokens/Elements/Optgroup.php 1 location

@@ 32-44 (lines=13) @@
29
        );
30
    }
31
32
    protected function removeInvalidChildren(LoggerInterface $logger)
33
    {
34
        foreach ($this->children as $child) {
35
            if ($child instanceof NonParticipating ||
36
                $child instanceof Option ||
37
                $child instanceof ScriptSupporting) {
38
                continue;
39
            }
40
41
            $logger->debug('Removing ' . $child . '. Only "option" and script supporting elements allowed as children of a "optgroup" element.');
42
            $this->removeChild($child);
43
        }
44
    }
45
46
    protected function removeInvalidSelf(LoggerInterface $logger)
47
    {

src/Tokens/Elements/Textarea.php 1 location

@@ 48-59 (lines=12) @@
45
        );
46
    }
47
48
    protected function removeInvalidChildren(LoggerInterface $logger)
49
    {
50
        foreach ($this->children as $child) {
51
            if ($child instanceof NonParticipating ||
52
                $child instanceof Text) {
53
                continue;
54
            }
55
56
            $logger->debug('Removing ' . $child . '. Only text is allowed as children of a "textarea" element.');
57
            $this->removeChild($child);
58
        }
59
    }
60
61
    public function isInteractiveContent()
62
    {

src/Tokens/Elements/Button.php 1 location

@@ 43-52 (lines=10) @@
40
        );
41
    }
42
43
    protected function removeInvalidChildren(LoggerInterface $logger)
44
    {
45
        foreach ($this->children as $child) {
46
            if ($child instanceof InteractiveContent &&
47
                $child->isInteractiveContent()) {
48
                $logger->debug('Removing ' . $child . '. No interactive content inside a "button" element.');
49
                $this->removeChild($child);
50
            }
51
        }
52
    }
53
54
    public function isInteractiveContent()
55
    {