Passed
Push — main ( c291e2...a2634b )
by Jean-Christophe
02:27
created

AbstractAclPart::getId_()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 2
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 1
c 0
b 0
f 0
nc 1
nop 0
dl 0
loc 2
ccs 0
cts 2
cp 0
crap 2
rs 10
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"=>"name","nullable"=>false,"dbType"=>"varchar(100)")
19
	 */
20
	#[\Ubiquity\attributes\items\Id()]
21
	#[\Ubiquity\attributes\items\Column(name:'name',nullable:false,dbType:'varchar(100)')]
22
	protected $name;
23
24 22
	public function __construct(?string $name = null) {
25 22
		$this->name = $name;
26
	}
27
28
	/**
29
	 *
30
	 * @return mixed
31
	 */
32 22
	public function getName() {
33 22
		return $this->name;
34
	}
35
36
	public function getId_() {
37
		return $this->name;
38
	}
39
40
	/**
41
	 *
42
	 * @param string $name
43
	 */
44 4
	public function setName($name) {
45 4
		$this->name = $name;
46
	}
47
48 5
	public function toArray(): array {
49 5
		return \get_object_vars($this);
50
	}
51
52 6
	public function fromArray(array $values) {
53 6
		foreach ($values as $k => $v) {
54 6
			$this->$k = $v;
55
		}
56
	}
57
58
	public function __toString() {
59
		return $this->name;
60
	}
61
62 3
	public function castAs(string $class) {
63 3
		return unserialize(sprintf('O:%d:"%s"%s', \strlen($class), $class, \strstr(\strstr(\serialize($this), '"'), ':')));
64
	}
65
}
66
67