Completed
Push — master ( 28256c...92a7d3 )
by Peter
20:38
created

MetaAnnotation::getMeta()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
ccs 0
cts 2
cp 0
rs 10
cc 1
eloc 2
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 http://maslosoft.com/addendum/ - maslosoft addendum
12
 * @link https://code.google.com/p/addendum/ - original addendum project
13
 */
14
15
namespace Maslosoft\Addendum\Collections;
16
17
use Maslosoft\Addendum\Annotation;
18
use Maslosoft\Addendum\Interfaces\AnnotationEntityInterface;
19
use Maslosoft\Addendum\Interfaces\MetaAnnotationInterface;
20
21
/**
22
 * Annotation used for Collections\Meta
23
 * @author Piotr
24
 */
25
abstract class MetaAnnotation extends Annotation implements MetaAnnotationInterface
26
{
27
28
	/**
29
	 * Name of annotated field/method/class
30
	 * @var string
31
	 */
32
	public $name = '';
33
34
	/**
35
	 * Model metadata object
36
	 *
37
	 * NOTE: Deprecation notice is only to discourage direct use in annotations, this is actually required
38
	 * @deprecated Use getMeta() instead
39
	 *
40
	 * @var Meta
41
	 */
42
	protected $_meta = null;
43
44
	/**
45
	 * Annotatins entity, it can be either class, property, or method
46
	 * Its conrete annotation implementation responsibility to decide what to do with it.
47
	 *
48
	 * NOTE: Deprecation notice is only to discourage direct use in annotations, this is actually required
49
	 * @deprecated Use getEntity() instead
50
	 *
51
	 * @var AnnotationEntityInterface
52
	 */
53
	protected $_entity = null;
54
55 21
	public function setName($name)
56
	{
57 21
		$this->name = $name;
58 21
	}
59
60
	/**
61
	 * Set metada class to be accessible for annotation for init etc. methods
62
	 * @param Meta $meta
63
	 */
64 21
	public function setMeta(Meta $meta)
65
	{
66 21
		$this->_meta = $meta;
1 ignored issue
show
Deprecated Code introduced by
The property Maslosoft\Addendum\Colle...\MetaAnnotation::$_meta has been deprecated with message: Use getMeta() instead

This property has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the property will be removed from the class and what other property to use instead.

Loading history...
67 21
	}
68
69
	/**
70
	 * Get metadata class for whole entity.
71
	 *
72
	 * This allows access to type, method or property in any annotation,
73
	 * regardles of it's location.
74
	 * 
75
	 * @return Meta
76
	 */
77
	public function getMeta()
78
	{
79
		return $this->_meta;
1 ignored issue
show
Deprecated Code introduced by
The property Maslosoft\Addendum\Colle...\MetaAnnotation::$_meta has been deprecated with message: Use getMeta() instead

This property has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the property will be removed from the class and what other property to use instead.

Loading history...
80
	}
81
82
	/**
83
	 * Set annotatins entity, it can be either class, property, or method
84
	 * @param AnnotationEntityInterface $entity
85
	 */
86 21
	public function setEntity(AnnotationEntityInterface $entity)
87
	{
88 21
		$this->_entity = $entity;
1 ignored issue
show
Deprecated Code introduced by
The property Maslosoft\Addendum\Colle...etaAnnotation::$_entity has been deprecated with message: Use getEntity() instead

This property has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the property will be removed from the class and what other property to use instead.

Loading history...
89 21
	}
90
91
	/**
92
	 * Get annotated entity.
93
	 *
94
	 * Use this in annotations definitions to define it's params, ie:
95
	 *
96
	 * ```php
97
	 * public function init()
98
	 * {
99
	 * 		$this->getEntity()->someValue = $this->value;
100
	 * }
101
	 * ```
102
	 *
103
	 * @return AnnotatedEntityInteface
104
	 */
105
	public function getEntity()
106
	{
107
		return $this->_entity;
1 ignored issue
show
Deprecated Code introduced by
The property Maslosoft\Addendum\Colle...etaAnnotation::$_entity has been deprecated with message: Use getEntity() instead

This property has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the property will be removed from the class and what other property to use instead.

Loading history...
108
	}
109
110
	/**
111
	 * This function should be called after all annotations are initialized.
112
	 * Any code that depends on other annotations can be executed here.
113
	 * NOTE: This is not ensured to run, its annotations container responsibility to call it.
114
	 */
115 21
	public function afterInit()
116
	{
117
		
118 21
	}
119
120
}
121