Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 4 |
|
0.00% |
0 / 2 |
CRAP | |
0.00% |
0 / 1 |
| AttributeRule | |
0.00% |
0 / 4 |
|
0.00% |
0 / 2 |
12 | |
0.00% |
0 / 1 |
| __construct | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| test | |
0.00% |
0 / 3 |
|
0.00% |
0 / 1 |
6 | |||
| 1 | <?php |
| 2 | |
| 3 | namespace pvc\html\rules\category_rules; |
| 4 | |
| 5 | use pvc\html\rules\AbstractRule; |
| 6 | use pvc\interfaces\html\content_model\ContentCategory; |
| 7 | use pvc\interfaces\html\dom\DomNodeInterface; |
| 8 | use pvc\interfaces\html\rules\CategoryRuleInterface; |
| 9 | |
| 10 | class AttributeRule extends AbstractRule implements CategoryRuleInterface |
| 11 | { |
| 12 | /** |
| 13 | * @param string $attribute, |
| 14 | * @param array<ContentCategory> $categories |
| 15 | */ |
| 16 | public function __construct( |
| 17 | protected string $attribute, |
| 18 | protected array $categories, |
| 19 | ) |
| 20 | { |
| 21 | } |
| 22 | |
| 23 | /** |
| 24 | * @param DomNodeInterface $content |
| 25 | * |
| 26 | * @return array<ContentCategory> |
| 27 | */ |
| 28 | public function test(DomNodeInterface $content): array |
| 29 | { |
| 30 | if ($content->getDomElement()->hasAttribute($this->attribute)) { |
| 31 | return $this->categories; |
| 32 | } |
| 33 | return []; |
| 34 | } |
| 35 | } |