Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 4
0.00% covered (danger)
0.00%
0 / 2
CRAP
0.00% covered (danger)
0.00%
0 / 1
CategoriesNotPermitted
0.00% covered (danger)
0.00%
0 / 4
0.00% covered (danger)
0.00%
0 / 2
12
0.00% covered (danger)
0.00%
0 / 1
 __construct
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 test
0.00% covered (danger)
0.00%
0 / 3
0.00% covered (danger)
0.00%
0 / 1
6
1<?php
2
3namespace pvc\html\rules\content_rules\not_permitted;
4
5use pvc\html\content_model\ContentModel;
6use pvc\html\rules\AbstractRule;
7use pvc\interfaces\html\content_model\ContentCategory;
8use pvc\interfaces\html\content_model\ContentPermission;
9use pvc\interfaces\html\dom\DomNodeInterface;
10use pvc\interfaces\html\rules\ContentRuleInterface;
11
12class 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}