Completed
Push — master ( 5154b1...1d4343 )
by Kevin
03:50
created

Input::isInteractiveContent()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2

Importance

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