Form::getAllowedAttributes()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 18
Code Lines 13

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 18
ccs 5
cts 5
cp 1
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 13
nc 1
nop 0
crap 1
1
<?php
2
3
namespace Groundskeeper\Tokens\Elements;
4
5
use Groundskeeper\Tokens\Attribute;
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 7
    protected function getAllowedAttributes()
17
    {
18
        $formAllowedAttributes = array(
19 7
            '/^accept-charset$/i' => Attribute::CS_STRING,
20
            '/^action$/i' => Attribute::URI,
21
            '/^autocomplete$/i' => Attribute::CI_ENUM . '("","on","off")',
22
            '/^enctype$/i' => Attribute::CS_STRING,
23
            '/^method$/i' => Attribute::CI_ENUM . '("","get","post","dialog"|"get")',
24
            '/^name$/i' => Attribute::CS_STRING,
25
            '/^novalidate$/i' => Attribute::BOOL,
26
            '/^target$/i' => Attribute::CS_STRING
27
        );
28
29 7
        return array_merge(
30 7
            $formAllowedAttributes,
31 7
            parent::getAllowedAttributes()
32
        );
33
    }
34
35 7 View Code Duplication
    protected function removeInvalidSelf(LoggerInterface $logger) : bool
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 7
        $form = new self($this->configuration, 0, 0, 'form');
38 7
        if ($this->hasAncestor($form)) {
39 1
            $logger->debug('Removing ' . $this . '. Cannot have a "form" element ancestor.');
40
41 1
            return true;
42
        }
43
44 7
        return false;
45
    }
46
}
47