Role::setParents()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2

Importance

Changes 0
Metric Value
cc 2
eloc 3
nc 2
nop 1
dl 0
loc 5
ccs 4
cts 4
cp 1
crap 2
rs 10
c 0
b 0
f 0
1
<?php
2
namespace Ubiquity\security\acl\models;
3
4
/**
5
 * Ubiquity\security\acl\models$Role
6
 * This class is part of Ubiquity
7
 *
8
 * @author jc
9
 * @version 1.0.0
10
 *
11
 */
12
class Role extends AbstractAclPart {
13
14 25
	public function __construct(?string $name = null, $parents = '') {
15 25
		parent::__construct($name);
16 25
		$this->setParents($parents);
17
	}
18
19
	/**
20
	 *
21
	 * @var string
22
	 */
23
	protected $parents = '';
24
25
	/**
26
	 *
27
	 * @return string
28
	 */
29
	public function getParents() {
30
		return $this->parents;
31
	}
32
33
	/**
34
	 *
35
	 * @return array
36
	 */
37 19
	public function getParentsArray() {
38 19
		return ($this->parents == null) ? [] : \explode(',', $this->parents);
39
	}
40
41
	/**
42
	 *
43
	 * @param array|string $parents
44
	 */
45 25
	public function setParents($parents) {
46 25
		if (\is_array($parents)) {
47 10
			$parents = \implode(',', $parents);
48
		}
49 25
		$this->parents = $parents;
50
	}
51
}
52
53