Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 4 |
|
0.00% |
0 / 2 |
CRAP | |
0.00% |
0 / 1 |
| CategoriesNotPermitted | |
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\content_rules\not_permitted; |
| 4 | |
| 5 | use pvc\html\content_model\ContentModel; |
| 6 | use pvc\html\rules\AbstractRule; |
| 7 | use pvc\interfaces\html\content_model\ContentCategory; |
| 8 | use pvc\interfaces\html\content_model\ContentPermission; |
| 9 | use pvc\interfaces\html\dom\DomNodeInterface; |
| 10 | use pvc\interfaces\html\rules\ContentRuleInterface; |
| 11 | |
| 12 | class CategoriesNotPermitted extends AbstractRule implements ContentRuleInterface |
| 13 | { |
| 14 | protected int $categories; |
| 15 | |
| 16 | /** |
| 17 | * @param array<ContentCategory> $categories |
| 18 | */ |
| 19 | public function __construct( |
| 20 | array $categories) |
| 21 | { |
| 22 | $this->categories = ContentModel::coalesceContentCategories($categories); |
| 23 | } |
| 24 | |
| 25 | /** |
| 26 | * @param DomNodeInterface $content |
| 27 | * |
| 28 | * @return ContentPermission |
| 29 | */ |
| 30 | public function test(DomNodeInterface $content): ContentPermission |
| 31 | { |
| 32 | return (0 < ($this->categories & $content->getContentModel()->getCategories())) ? |
| 33 | ContentPermission::DENIED : |
| 34 | ContentPermission::NOT_APPLICABLE; |
| 35 | } |
| 36 | } |