Completed
Push — master ( d8e3ee...0777f1 )
by Kevin
03:18
created

Form::getAllowedAttributes()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 18
Code Lines 13

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 13
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 18
ccs 13
cts 13
cp 1
rs 9.4285
cc 1
eloc 13
nc 1
nop 0
crap 1
1
<?php
2
3
namespace Groundskeeper\Tokens\Elements;
4
5
use Groundskeeper\Tokens\Element;
6
use Groundskeeper\Tokens\ElementTypes\OpenElement;
7
use Psr\Log\LoggerInterface;
8
9
/**
10
 * "form" element
11
 *
12
 * https://html.spec.whatwg.org/multipage/forms.html#the-form-element
13
 */
14
class Form extends OpenElement
15
{
16 1
    protected function getAllowedAttributes()
17
    {
18
        $formAllowedAttributes = array(
19 1
            '/^accept-charset$/i' => Element::ATTR_CS_STRING,
20 1
            '/^action$/i' => Element::ATTR_URI,
21 1
            '/^autocomplete$/i' => Element::ATTR_CI_ENUM . '("","on","off")',
22 1
            '/^enctype$/i' => Element::ATTR_CS_STRING,
23 1
            '/^method$/i' => Element::ATTR_CI_ENUM . '("","get","post","dialog"|"get")',
24 1
            '/^name$/i' => Element::ATTR_CS_STRING,
25 1
            '/^novalidate$/i' => Element::ATTR_BOOL,
26
            '/^target$/i' => Element::ATTR_CS_STRING
27 1
        );
28
29 1
        return array_merge(
30 1
            $formAllowedAttributes,
31 1
            parent::getAllowedAttributes()
32 1
        );
33
    }
34
35 1 View Code Duplication
    protected function removeInvalidSelf(LoggerInterface $logger)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
36
    {
37 1
        $form = new self($this->configuration, 'form');
38 1
        if ($this->hasAncestor($form)) {
39
            $logger->debug('Removing ' . $this . '. Cannot be have a "form" element ancestor.');
40
41
            return true;
42
        }
43
44 1
        return false;
45
    }
46
}
47