Test Failed
Push — main ( 573841...5a0b4f )
by Jean-Christophe
06:17
created

PermissionAnnotation::initAnnotation()   A

Complexity

Conditions 5
Paths 5

Size

Total Lines 15
Code Lines 12

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 5
eloc 12
c 1
b 0
f 0
nc 5
nop 1
dl 0
loc 15
rs 9.5555
1
<?php
2
namespace Ubiquity\annotations\acl;
3
4
use Ubiquity\annotations\BaseAnnotation;
0 ignored issues
show
Bug introduced by
The type Ubiquity\annotations\BaseAnnotation 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...
5
6
/**
7
 * Annotation Permission.
8
 * usages :
9
 * - permission("permissionName")
10
 * - permission("permissionName","permissionLevel")
11
 * - permission("name"=>"permissionName")
12
 * - permission("name"=>"permissionName","level"=>"permissionLevel")
13
 *
14
 * @author jc
15
 * @version 1.0.0
16
 * @usage('method'=>true,'class'=>true,'inherited'=>true,'multiple'=>false)
17
 */
18
class PermissionAnnotation extends BaseAnnotation {
19
20
	public $name;
21
22
	public $level;
23
24
	/**
25
	 * Initialize the annotation.
26
	 */
27
	public function initAnnotation(array $properties) {
28
		if (isset($properties[0])) {
29
			$this->name = $properties[0];
30
			unset($properties[0]);
31
			if (isset($properties[1])) {
32
				$this->level = $properties[1];
33
				unset($properties[1]);
34
			}
35
		} else if (isset($properties['name'])) {
36
			$this->name = $properties['name'];
37
			if (isset($properties['level'])) {
38
				$this->level = $properties['level'];
39
			}
40
		} else {
41
			throw new \Exception('Permission annotation must have a name');
42
		}
43
	}
44
}
45