PolicyRule::setName()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 6
ccs 3
cts 3
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
crap 1
1
<?php
2
3
namespace PhpAbac\Model;
4
5
class PolicyRule
6
{
7
    /** @var string **/
8
    protected $name;
9
    /** @var array<PolicyRuleAttribute> **/
10
    protected $policyRuleAttributes;
11
12 6
    public function __construct()
13
    {
14 6
        $this->policyRuleAttributes = [];
15 6
    }
16
17 6
    public function setName(string $name): PolicyRule
18
    {
19 6
        $this->name = $name;
20
21 6
        return $this;
22
    }
23
24 2
    public function getName(): string
25
    {
26 2
        return $this->name;
27
    }
28
29 6
    public function addPolicyRuleAttribute(PolicyRuleAttribute $pra): PolicyRule
30
    {
31 6
        if (!in_array($pra, $this->policyRuleAttributes, true)) {
32 6
            $this->policyRuleAttributes[] = $pra;
33
        }
34 6
        return $this;
35
    }
36
37 1
    public function removePolicyRuleAttribute(PolicyRuleAttribute $pra): PolicyRule
38
    {
39 1
        if (($key = array_search($pra, $this->policyRuleAttributes)) !== false) {
40 1
            unset($this->policyRuleAttributes[$key]);
41
        }
42
43 1
        return $this;
44
    }
45
46 6
    public function getPolicyRuleAttributes(): array
47
    {
48 6
        return $this->policyRuleAttributes;
49
    }
50
}
51