Passed
Push — main ( 6d76a8...9a92e8 )
by Jean-Christophe
02:58 queued 15s
created

AbstractAclPart::castAs()   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 1
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
use Ubiquity\attributes\items\Transient;
1 ignored issue
show
Bug introduced by
The type Ubiquity\attributes\items\Transient was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

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