1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* AppserverIo\Psr\EnterpriseBeans\Annotations\AbstractBeanAnnotation |
5
|
|
|
* |
6
|
|
|
* NOTICE OF LICENSE |
7
|
|
|
* |
8
|
|
|
* This source file is subject to the Open Software License (OSL 3.0) |
9
|
|
|
* that is available through the world-wide-web at this URL: |
10
|
|
|
* http://opensource.org/licenses/osl-3.0.php |
11
|
|
|
* |
12
|
|
|
* PHP version 5 |
13
|
|
|
* |
14
|
|
|
* @author Tim Wagner <[email protected]> |
15
|
|
|
* @copyright 2015 TechDivision GmbH <[email protected]> |
16
|
|
|
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) |
17
|
|
|
* @link https://github.com/appserver-io-psr/epb |
18
|
|
|
* @link http://www.appserver.io |
19
|
|
|
*/ |
20
|
|
|
|
21
|
|
|
namespace AppserverIo\Psr\EnterpriseBeans\Annotations; |
22
|
|
|
|
23
|
|
|
/** |
24
|
|
|
* Abstract bean annotation implementation. |
25
|
|
|
* |
26
|
|
|
* @author Tim Wagner <[email protected]> |
27
|
|
|
* @copyright 2015 TechDivision GmbH <[email protected]> |
28
|
|
|
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) |
29
|
|
|
* @link https://github.com/appserver-io-psr/epb |
30
|
|
|
* @link http://www.appserver.io |
31
|
|
|
*/ |
32
|
|
View Code Duplication |
abstract class AbstractBeanAnnotation extends AbstractAnnotation |
|
|
|
|
33
|
|
|
{ |
34
|
|
|
|
35
|
|
|
/** |
36
|
|
|
* The value of the name attribute. |
37
|
|
|
* |
38
|
|
|
* @var string |
39
|
|
|
*/ |
40
|
|
|
protected $name; |
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* The value of the description attribute. |
44
|
|
|
* |
45
|
|
|
* @var string |
46
|
|
|
*/ |
47
|
|
|
protected $description; |
48
|
|
|
|
49
|
|
|
/** |
50
|
|
|
* The value of the lookup attribute. |
51
|
|
|
* |
52
|
|
|
* @var string |
53
|
|
|
*/ |
54
|
|
|
protected $lookup; |
55
|
|
|
|
56
|
|
|
/** |
57
|
|
|
* The value of the shared attribute. |
58
|
|
|
* |
59
|
|
|
* @var boolean |
60
|
|
|
*/ |
61
|
|
|
protected $shared = true; |
62
|
|
|
|
63
|
|
|
/** |
64
|
|
|
* The constructor the initializes the instance with the |
65
|
|
|
* data passed with the token. |
66
|
|
|
* |
67
|
|
|
* @param array $values The annotation values |
68
|
|
|
*/ |
69
|
|
|
public function __construct(array $values = array()) |
70
|
|
|
{ |
71
|
|
|
|
72
|
|
|
// set the name attribute, if available |
73
|
|
|
if (isset($values[AnnotationKeys::NAME])) { |
74
|
|
|
$this->name = $values[AnnotationKeys::NAME]; |
75
|
|
|
} |
76
|
|
|
|
77
|
|
|
// set the description attribute, if available |
78
|
|
|
if (isset($values[AnnotationKeys::DESCRIPTION])) { |
79
|
|
|
$this->description = $values[AnnotationKeys::DESCRIPTION]; |
80
|
|
|
} |
81
|
|
|
|
82
|
|
|
// set the lookup attribute, if available |
83
|
|
|
if (isset($values[AnnotationKeys::LOOKUP])) { |
84
|
|
|
$this->lookup = $values[AnnotationKeys::LOOKUP]; |
85
|
|
|
} |
86
|
|
|
|
87
|
|
|
// set the shared attribute, if available |
88
|
|
|
if (isset($values[AnnotationKeys::SHARED])) { |
89
|
|
|
$this->shared = $values[AnnotationKeys::SHARED]; |
90
|
|
|
} |
91
|
|
|
} |
92
|
|
|
|
93
|
|
|
/** |
94
|
|
|
* Returns the value of the name attribute. |
95
|
|
|
* |
96
|
|
|
* @return string|null The annotations name attribute |
97
|
|
|
*/ |
98
|
|
|
public function getName() |
99
|
|
|
{ |
100
|
|
|
return $this->name; |
101
|
|
|
} |
102
|
|
|
|
103
|
|
|
/** |
104
|
|
|
* Returns the value of the description attribute. |
105
|
|
|
* |
106
|
|
|
* @return string|null The annotations description attribute |
107
|
|
|
*/ |
108
|
|
|
public function getDescription() |
109
|
|
|
{ |
110
|
|
|
return $this->description; |
111
|
|
|
} |
112
|
|
|
|
113
|
|
|
/** |
114
|
|
|
* Returns the value of the lookup attribute. |
115
|
|
|
* |
116
|
|
|
* @return string|null The annotations lookup attribute |
117
|
|
|
*/ |
118
|
|
|
public function getLookup() |
119
|
|
|
{ |
120
|
|
|
return $this->lookup; |
121
|
|
|
} |
122
|
|
|
|
123
|
|
|
/** |
124
|
|
|
* Returns the value of the shared attribute. |
125
|
|
|
* |
126
|
|
|
* @return boolean The annotations shared attribute |
127
|
|
|
*/ |
128
|
|
|
public function getShared() |
129
|
|
|
{ |
130
|
|
|
return $this->shared; |
131
|
|
|
} |
132
|
|
|
} |
133
|
|
|
|
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.