PolicyRule   A
last analyzed

Complexity

Total Complexity 8

Size/Duplication

Total Lines 46
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 8
lcom 1
cbo 0
dl 0
loc 46
ccs 18
cts 18
cp 1
rs 10
c 0
b 0
f 0

6 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A setName() 0 6 1
A getName() 0 4 1
A addPolicyRuleAttribute() 0 7 2
A removePolicyRuleAttribute() 0 8 2
A getPolicyRuleAttributes() 0 4 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