Completed
Push — master ( 64950e...559766 )
by Kevin
03:41
created

Textarea::getAllowedAttributes()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 25
Code Lines 20

Duplication

Lines 25
Ratio 100 %

Code Coverage

Tests 21
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 25
loc 25
ccs 21
cts 21
cp 1
rs 8.8571
cc 1
eloc 20
nc 1
nop 0
crap 1
1
<?php
2
3
namespace Groundskeeper\Tokens\Elements;
4
5
use Groundskeeper\Tokens\Attribute;
6
use Groundskeeper\Tokens\Element;
7
use Groundskeeper\Tokens\ElementTypes\FlowContent;
8
use Groundskeeper\Tokens\ElementTypes\InteractiveContent;
9
use Groundskeeper\Tokens\ElementTypes\OpenElement;
10
use Groundskeeper\Tokens\ElementTypes\PhrasingContent;
11
use Groundskeeper\Tokens\NonParticipating;
12
use Groundskeeper\Tokens\Text;
13
use Psr\Log\LoggerInterface;
14
15
/**
16
 * "textarea" element
17
 *
18
 * https://html.spec.whatwg.org/multipage/forms.html#the-textarea-element
19
 */
20
class Textarea extends OpenElement implements FlowContent, InteractiveContent, PhrasingContent
21
{
22 2 View Code Duplication
    protected function getAllowedAttributes()
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...
23
    {
24
        $textareaAllowedAttributes = array(
25 2
            '/^autocomplete$/i' => Attribute::CS_STRING,
26 2
            '/^autofocus$/i' => Attribute::BOOL,
27 2
            '/^cols$/i' => Attribute::INT,
28 2
            '/^dirname$/i' => Attribute::CS_STRING,
29 2
            '/^disabled$/i' => Attribute::BOOL,
30 2
            '/^form$/i' => Attribute::CS_STRING,
31 2
            '/^inputmode$/i' => Attribute::CS_STRING,
32 2
            '/^maxlength$/i' => Attribute::CS_STRING,
33 2
            '/^minlength$/i' => Attribute::CS_STRING,
34 2
            '/^name$/i' => Attribute::CS_STRING,
35 2
            '/^placeholder$/i' => Attribute::CS_STRING,
36 2
            '/^readonly$/i' => Attribute::BOOL,
37 2
            '/^required$/i' => Attribute::BOOL,
38 2
            '/^rows$/i' => Attribute::INT,
39 2
            '/^wrap$/i' => Attribute::CI_ENUM . '("","soft","hard"|"soft")'
40 2
        );
41
42 2
        return array_merge(
43 2
            $textareaAllowedAttributes,
44 2
            parent::getAllowedAttributes()
45 2
        );
46
    }
47
48 2 View Code Duplication
    protected function removeInvalidChildren(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...
49
    {
50 2
        foreach ($this->children as $child) {
51 2
            if ($child instanceof NonParticipating ||
52 2
                $child instanceof Text) {
53 2
                continue;
54
            }
55
56 1
            $logger->debug('Removing ' . $child . '. Only text is allowed as children of a "textarea" element.');
57 1
            $this->removeChild($child);
58 2
        }
59 2
    }
60
61
    public function isInteractiveContent()
62
    {
63
        return true;
64
    }
65
}
66