Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 4 |
|
0.00% |
0 / 1 |
CRAP | |
0.00% |
0 / 1 |
ButtonContentRule | |
0.00% |
0 / 4 |
|
0.00% |
0 / 1 |
12 | |
0.00% |
0 / 1 |
test | |
0.00% |
0 / 4 |
|
0.00% |
0 / 1 |
12 |
1 | <?php |
2 | |
3 | namespace pvc\html\rules\content_rules\permitted; |
4 | |
5 | use pvc\html\rules\AbstractRule; |
6 | use pvc\html\rules\ContentIdentify; |
7 | use pvc\interfaces\html\content_model\ContentPermission; |
8 | use pvc\interfaces\html\dom\DomNodeInterface; |
9 | use pvc\interfaces\html\rules\ContentRuleInterface; |
10 | |
11 | class ButtonContentRule extends AbstractRule implements ContentRuleInterface |
12 | { |
13 | /** |
14 | * @param DomNodeInterface $content |
15 | * |
16 | * @return ContentPermission |
17 | * looking for a very specific scenario where the containing node is a button, |
18 | * it is the first child of a select element, and the proposed content is a |
19 | * 'selectedContent' element |
20 | */ |
21 | public function test(DomNodeInterface $content): ContentPermission |
22 | { |
23 | if ( |
24 | $this->hasParentWith(ContentIdentify::customizableSelect(...)) && |
25 | $content->getDomElement()->hasName('selectedContent') |
26 | ) return ContentPermission::GRANTED; |
27 | |
28 | return ContentPermission::NOT_APPLICABLE; |
29 | } |
30 | } |