Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 4 |
|
0.00% |
0 / 2 |
CRAP | |
0.00% |
0 / 1 |
AttributesNotPermitted | |
0.00% |
0 / 4 |
|
0.00% |
0 / 2 |
20 | |
0.00% |
0 / 1 |
__construct | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
test | |
0.00% |
0 / 3 |
|
0.00% |
0 / 1 |
12 |
1 | <?php |
2 | |
3 | namespace pvc\html\rules\content_rules\not_permitted; |
4 | |
5 | use pvc\html\rules\AbstractRule; |
6 | use pvc\interfaces\html\content_model\ContentPermission; |
7 | use pvc\interfaces\html\dom\DomNodeInterface; |
8 | use pvc\interfaces\html\rules\ContentRuleInterface; |
9 | |
10 | class AttributesNotPermitted extends AbstractRule implements ContentRuleInterface |
11 | { |
12 | /** |
13 | * @param array<string> $attributeNames |
14 | */ |
15 | public function __construct( |
16 | protected array $attributeNames) |
17 | { |
18 | } |
19 | |
20 | /** |
21 | * @param DomNodeInterface $content |
22 | * |
23 | * @return ContentPermission |
24 | */ |
25 | public function test(DomNodeInterface $content): ContentPermission |
26 | { |
27 | foreach ($this->attributeNames as $attributeName) { |
28 | if ($content->getDomElement()->hasAttribute($attributeName)) return ContentPermission::DENIED; |
29 | } |
30 | return ContentPermission::NOT_APPLICABLE; |
31 | } |
32 | } |