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

AbstractAclPart   A

Complexity

Total Complexity 11

Size/Duplication

Total Lines 72
Duplicated Lines 0 %

Test Coverage

Coverage 84%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 15
dl 0
loc 72
ccs 21
cts 25
cp 0.84
rs 10
c 2
b 0
f 0
wmc 11

10 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 2 1
A __toString() 0 2 1
A fromArray() 0 3 2
A getId() 0 2 1
A setName() 0 2 1
A getName() 0 2 1
A setId() 0 2 1
A castAs() 0 2 1
A toArray() 0 2 1
A getId_() 0 2 1
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