TargetAnnotation::init()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 0
cts 2
cp 0
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 2
1
<?php
2
3
/**
4
 * This software package is licensed under AGPL, Commercial license.
5
 *
6
 * @package maslosoft/addendum
7
 * @licence AGPL, Commercial
8
 * @copyright Copyright (c) Piotr Masełkowski <[email protected]> (Meta container, further improvements, bugfixes)
9
 * @copyright Copyright (c) Maslosoft (Meta container, further improvements, bugfixes)
10
 * @copyright Copyright (c) Jan Suchal (Original version, builder, parser)
11
 * @link https://maslosoft.com/addendum/ - maslosoft addendum
12
 * @link https://code.google.com/p/addendum/ - original addendum project
13
 */
14
15
namespace Maslosoft\Addendum\Annotations;
16
17
use Maslosoft\Addendum\Annotation;
18
19
/**
20
 * Annotation target annotation
21
 * This allow limiting annotation use for properties, class,
22
 * method or concrete type
23
 * Valid values are
24
 *
25
 * * `class` - limit annotation for class only
26
 * * `method` - limit annotation for method only
27
 * * `property` - limit annotation for property only
28
 * * `nested` - set this to allow use of annotation only as nested annotation
29
 * * Any existing class name - to restrict use of annotation only on concrete class or its descendants
30
 *
31
 * Examples:
32
 *
33
 * Allow only on selected class and subclasses
34
 *
35
 * ```
36
 * @Target(Some\Target\ClassName)
37
 * ```
38
 *
39
 * When use statement for `Some\Target\ClassName` is provided, it could be shortened:
40
 * ```
41
 * @Target(ClassName)
42
 * ```
43
 *
44
 * Several targets can be specified.
45
 * Only on this class and subclasses - on properties:
46
 * ```
47
 * @Target(Some\Target\ClassName)
48
 * @Target('property')
49
 * ```
50
 * Only on this class and subclasses - on methods:
51
 * ```
52
 * @Target('Some\Target\ClassName')
53
 * @Target('method')
54
 * ```
55
 * On methods and properties:
56
 * ```
57
 * @Target('method')
58
 * @Target('property')
59
 * ```
60
 *
61
 * @template Target('${target}')
62
 */
63
class TargetAnnotation extends Annotation
64
{
65
66
	/**
67
	 * For internal use
68
	 */
69
	const Ns = __NAMESPACE__;
70
	const TargetClass = 'class';
71
	const TargetMethod = 'method';
72
	const TargetProperty = 'property';
73
	const TargetNested = 'nested';
74
75
	public $value;
76
	public $class = '';
77
78 6
	public static function getTargets()
79
	{
80
		return [
81 6
			self::TargetClass,
82 6
			self::TargetMethod,
83 6
			self::TargetProperty,
84 6
			self::TargetNested
85
		];
86
	}
87
88
	public function init()
89
	{
90
		
91
	}
92
93
}
94