Passed
Push — main ( 8815d3...d06024 )
by Jean-Christophe
02:38
created

AbstractAclPart::getId()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 2
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 2
ccs 2
cts 2
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Ubiquity\security\acl\models;
4
5
/**
6
 * Ubiquity\security\acl\models$AbastractAclElement
7
 * This class is part of Ubiquity
8
 *
9
 * @author jc
10
 * @version 1.0.1
11
 *
12
 */
13
abstract class AbstractAclPart {
14
15
	/**
16
	 *
17
	 * @id
18
	 * @column("name"=>"id","nullable"=>false,"dbType"=>"int(11)")
19
	 */
20
	#[\Ubiquity\attributes\items\Id()]
21
	protected $id;
22
23
	/**
24
	 *
25
	 * @var string
26
	 */
27
	protected $name;
28
29 22
	public function __construct(?string $name = null) {
30 22
		$this->name = $name;
31 22
	}
32
33
	/**
34
	 *
35
	 * @return mixed
36
	 */
37 22
	public function getName() {
38 22
		return $this->name;
39
	}
40
41
	/**
42
	 *
43
	 * @param string $name
44
	 */
45 4
	public function setName($name) {
46 4
		$this->name = $name;
47 4
	}
48
49 5
	public function toArray(): array {
50 5
		return \get_object_vars($this);
51
	}
52
53 6
	public function fromArray(array $values) {
54 6
		foreach ($values as $k => $v) {
55 6
			$this->$k = $v;
56
		}
57 6
	}
58
59
	/**
60
	 *
61
	 * @return mixed
62
	 */
63 3
	public function getId() {
64 3
		return $this->id;
65
	}
66
67
	public function getId_() {
68
		return $this->name;
69
	}
70
71
	/**
72
	 *
73
	 * @param mixed $id
74
	 */
75 4
	public function setId($id) {
76 4
		$this->id = $id;
77 4
	}
78
79
	public function __toString() {
80
		return $this->name;
81
	}
82
83 3
	public function castAs(string $class) {
84 3
		return unserialize(sprintf('O:%d:"%s"%s', \strlen($class), $class, \strstr(\strstr(\serialize($this), '"'), ':')));
85
	}
86
}
87
88