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 |
|
|
|
|
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
|
|
|
|
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.