Completed
Push — master ( 91ab9a...64950e )
by Kevin
04:15
created

Input::removeInvalidSelf()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 11
Code Lines 6

Duplication

Lines 11
Ratio 100 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 1
Bugs 1 Features 1
Metric Value
c 1
b 1
f 1
dl 11
loc 11
ccs 0
cts 9
cp 0
rs 9.4285
cc 2
eloc 6
nc 2
nop 1
crap 6
1
<?php
2
3
namespace Groundskeeper\Tokens\Elements;
4
5
use Groundskeeper\Tokens\Attribute;
6
use Groundskeeper\Tokens\ElementTypes\ClosedElement;
7
use Groundskeeper\Tokens\ElementTypes\FlowContent;
8
use Groundskeeper\Tokens\ElementTypes\InteractiveContent;
9
use Groundskeeper\Tokens\ElementTypes\PhrasingContent;
10
use Psr\Log\LoggerInterface;
11
12
/**
13
 * "input" element
14
 *
15
 * https://html.spec.whatwg.org/multipage/forms.html#the-input-element
16
 */
17
class Input extends ClosedElement implements FlowContent, InteractiveContent, PhrasingContent
18
{
19 4
    protected function getAllowedAttributes()
20
    {
21
        $inputAllowedAttributes = array(
22 4
            '/^accept$/i' => Attribute::CI_STRING,
23 4
            '/^alt$/i' => Attribute::CS_STRING,
24 4
            '/^autocomplete$/i' => Attribute::CS_STRING,
25 4
            '/^autofocus$/i' => Attribute::BOOL,
26 4
            '/^checked$/i' => Attribute::BOOL,
27 4
            '/^dirname$/i' => Attribute::CS_STRING,
28 4
            '/^disabled$/i' => Attribute::BOOL,
29 4
            '/^form$/i' => Attribute::CS_STRING,
30 4
            '/^formaction$/i' => Attribute::URI,
31 4
            '/^formenctype$/i' => Attribute::CS_STRING,
32 4
            '/^formmethod$/i' => Attribute::CI_ENUM . '("","get","post","dialog"|"get")',
33 4
            '/^formnovalidate$/i' => Attribute::BOOL,
34 4
            '/^formtarget$/i' => Attribute::CS_STRING,
35 4
            '/^height$/i' => Attribute::INT,
36 4
            '/^inputmode$/i' => Attribute::CI_STRING,
37 4
            '/^list$/i' => Attribute::CS_STRING,
38 4
            '/^max$/i' => Attribute::CS_STRING,
39 4
            '/^maxlength$/i' => Attribute::INT,
40 4
            '/^min$/i' => Attribute::CS_STRING,
41 4
            '/^minlength$/i' => Attribute::INT,
42 4
            '/^multiple$/i' => Attribute::BOOL,
43 4
            '/^name$/i' => Attribute::CS_STRING,
44 4
            '/^pattern$/i' => Attribute::CS_STRING,
45 4
            '/^placeholder$/i' => Attribute::CS_STRING,
46 4
            '/^readonly$/i' => Attribute::BOOL,
47 4
            '/^required$/i' => Attribute::BOOL,
48 4
            '/^size$/i' => Attribute::INT,
49 4
            '/^src$/i' => Attribute::URI,
50 4
            '/^step$/i' => Attribute::CI_STRING,
51 4
            '/^type$/i' => Attribute::CI_ENUM . '("hidden","text","search","tel","url","email","password","date","month","week","time","datetime-local","number","range","color","checkbox","radio","file","submit","image","reset","button"|"text")',
52 4
            '/^value$/i' => Attribute::CS_STRING,
53
            '/^width$/i' => Attribute::INT
54 4
        );
55
56 4
        return array_merge(
57 4
            $inputAllowedAttributes,
58 4
            parent::getAllowedAttributes()
59 4
        );
60
    }
61
62
    public function isInteractiveContent()
63
    {
64
        if (!$this->hasAttribute('type')) {
65
            return true;
66
        }
67
68
        return $this->getAttribute('type') !== 'hidden';
69
    }
70
}
71