Code Duplication    Length = 30-32 lines in 2 locations

src/Tokens/Elements/Param.php 1 location

@@ 15-44 (lines=30) @@
12
 *
13
 * https://html.spec.whatwg.org/multipage/semantics.html#the-param-element
14
 */
15
class Param extends ClosedElement
16
{
17
    protected function getAllowedAttributes()
18
    {
19
        $paramAllowedAttributes = array(
20
            '/^name$/i' => Element::ATTR_CS_STRING,
21
            '/^value$/i' => Element::ATTR_CS_STRING
22
        );
23
24
        return array_merge(
25
            $paramAllowedAttributes,
26
            parent::getAllowedAttributes()
27
        );
28
    }
29
30
    protected function doClean(LoggerInterface $logger)
31
    {
32
        if ($this->configuration->get('clean-strategy') != Configuration::CLEAN_STRATEGY_LENIENT) {
33
            // Must be child of "object" element.
34
            $parent = $this->getParent();
35
            if ($parent !== null && $parent->getName() !== 'object') {
36
                $logger->debug('Element "param" must be a child of "object" element.');
37
38
                return false;
39
            }
40
        }
41
42
        return true;
43
    }
44
}
45

src/Tokens/Elements/Td.php 1 location

@@ 16-47 (lines=32) @@
13
 *
14
 * https://html.spec.whatwg.org/multipage/semantics.html#the-td-element
15
 */
16
class Td extends OpenElement implements SectioningRoot
17
{
18
    protected function getAllowedAttributes()
19
    {
20
        $tdAllowedAttributes = array(
21
            '/^colspan$/i' => Element::ATTR_INT,
22
            '/^rowspan$/i' => Element::ATTR_INT,
23
            '/^headers$/i' => Element::ATTR_CS_STRING
24
        );
25
26
        return array_merge(
27
            $tdAllowedAttributes,
28
            parent::getAllowedAttributes()
29
        );
30
    }
31
32
    protected function doClean(LoggerInterface $logger)
33
    {
34
        if ($this->configuration->get('clean-strategy') != Configuration::CLEAN_STRATEGY_LENIENT) {
35
            // "tr" must be parent.
36
            $parent = $this->getParent();
37
            if ($parent !== null &&
38
                $parent->getName() != 'tr') {
39
                $logger->debug('Element "td" must be a child of "tr" element.');
40
41
                return false;
42
            }
43
        }
44
45
        return true;
46
    }
47
}
48