Passed
Push — main ( 778532...d55b52 )
by Jean-Christophe
02:11
created

AbstractAclPart::fromArray()   A

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
c 0
b 0
f 0
nc 2
nop 1
dl 0
loc 5
rs 10
ccs 4
cts 4
cp 1
crap 2
1
<?php
2
namespace Ubiquity\security\acl\models;
3
4
/**
5
 * Ubiquity\security\acl\models$AbastractAclElement
6
 * This class is part of Ubiquity
7
 *
8
 * @author jc
9
 * @version 1.0.0
10
 *
11
 */
12
abstract class AbstractAclPart {
13
14
	/**
15
	 *
16
	 * @id
17
	 * @column("name"=>"id","nullable"=>false,"dbType"=>"int(11)")
18
	 */
19
	protected $id;
20
21
	/**
22
	 *
23
	 * @var string
24
	 */
25
	protected $name;
26
27 22
	public function __construct(?string $name = null) {
28 22
		$this->name = $name;
29 22
	}
30
31
	/**
32
	 *
33
	 * @return mixed
34
	 */
35 22
	public function getName() {
36 22
		return $this->name;
37
	}
38
39
	/**
40
	 *
41
	 * @param string $name
42
	 */
43 4
	public function setName($name) {
44 4
		$this->name = $name;
45 4
	}
46
47 6
	public function toArray(): array {
48 6
		return \get_object_vars($this);
49
	}
50
51 6
	public function fromArray(array $values) {
52 6
		foreach ($values as $k => $v) {
53 6
			$this->$k = $v;
54
		}
55 6
		$this->_fromArray = true;
1 ignored issue
show
Bug Best Practice introduced by
The property _fromArray does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
56 6
	}
57
58
	/**
59
	 *
60
	 * @return mixed
61
	 */
62
	public function getId() {
63
		return $this->id;
64
	}
65
66
	public function getId_() {
67
		return $this->name;
68
	}
69
70
	/**
71
	 *
72
	 * @param mixed $id
73
	 */
74 4
	public function setId($id) {
75 4
		$this->id = $id;
76 4
	}
77
78
	public function __toString() {
79
		return $this->name;
80
	}
81
}
82
83