1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* AppserverIo\Routlt\Annotations\Result |
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 http://github.com/appserver-io/routlt |
18
|
|
|
* @link http://www.appserver.io |
19
|
|
|
*/ |
20
|
|
|
|
21
|
|
|
namespace AppserverIo\Routlt\Annotations; |
22
|
|
|
|
23
|
|
|
use AppserverIo\Psr\EnterpriseBeans\Annotations\AbstractBeanAnnotation; |
24
|
|
|
|
25
|
|
|
/** |
26
|
|
|
* Annotation to map a string to a action result. |
27
|
|
|
* |
28
|
|
|
* @author Tim Wagner <[email protected]> |
29
|
|
|
* @copyright 2015 TechDivision GmbH <[email protected]> |
30
|
|
|
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) |
31
|
|
|
* @link http://github.com/appserver-io/routlt |
32
|
|
|
* @link http://www.appserver.io |
33
|
|
|
* |
34
|
|
|
* @Annotation |
35
|
|
|
* @Target({"CLASS", "ANNOTATION"}) |
36
|
|
|
*/ |
37
|
|
|
class Result extends AbstractBeanAnnotation |
38
|
|
|
{ |
39
|
|
|
|
40
|
|
|
/** |
41
|
|
|
* The value of the type attribute. |
42
|
|
|
* |
43
|
|
|
* @var string |
44
|
|
|
*/ |
45
|
|
|
protected $type; |
46
|
|
|
|
47
|
|
|
/** |
48
|
|
|
* The value of the code attribute. |
49
|
|
|
* |
50
|
|
|
* @var string |
51
|
|
|
*/ |
52
|
|
|
protected $code; |
53
|
|
|
|
54
|
|
|
/** |
55
|
|
|
* The value of the result attribute. |
56
|
|
|
* |
57
|
|
|
* @var string |
58
|
|
|
*/ |
59
|
|
|
protected $result; |
60
|
|
|
|
61
|
|
|
/** |
62
|
|
|
* The constructor the initializes the instance with the |
63
|
|
|
* data passed with the token. |
64
|
|
|
* |
65
|
|
|
* @param array $values The annotation values |
66
|
|
|
*/ |
67
|
9 |
View Code Duplication |
public function __construct(array $values = array()) |
|
|
|
|
68
|
|
|
{ |
69
|
|
|
|
70
|
|
|
// set the type attribute, if available |
71
|
9 |
|
if (isset($values[AnnotationKeys::TYPE])) { |
72
|
9 |
|
$this->type = $values[AnnotationKeys::TYPE]; |
73
|
9 |
|
} |
74
|
|
|
|
75
|
|
|
// set the code attribute, if available |
76
|
9 |
|
if (isset($values[AnnotationKeys::CODE])) { |
77
|
|
|
$this->code = $values[AnnotationKeys::CODE]; |
78
|
|
|
} |
79
|
|
|
|
80
|
|
|
// set the result attribute, if available |
81
|
9 |
|
if (isset($values[AnnotationKeys::RESULT])) { |
82
|
9 |
|
$this->result = $values[AnnotationKeys::RESULT]; |
83
|
9 |
|
} |
84
|
|
|
|
85
|
|
|
// pass the arguements through to the parent instance |
86
|
9 |
|
parent::__construct($values); |
87
|
9 |
|
} |
88
|
|
|
|
89
|
|
|
/** |
90
|
|
|
* Returns the value of the type attribute. |
91
|
|
|
* |
92
|
|
|
* @return string|null The annotations type attribute |
93
|
|
|
*/ |
94
|
5 |
|
public function getType() |
95
|
|
|
{ |
96
|
5 |
|
return $this->type; |
97
|
|
|
} |
98
|
|
|
|
99
|
|
|
/** |
100
|
|
|
* Returns the value of the result attribute. |
101
|
|
|
* |
102
|
|
|
* @return string|null The annotations result attribute |
103
|
|
|
*/ |
104
|
5 |
|
public function getResult() |
105
|
|
|
{ |
106
|
5 |
|
return $this->result; |
107
|
|
|
} |
108
|
|
|
|
109
|
|
|
/** |
110
|
|
|
* Returns the value of the code attribute. |
111
|
|
|
* |
112
|
|
|
* @return string|null The annotations code attribute |
113
|
|
|
*/ |
114
|
5 |
|
public function getCode() |
115
|
|
|
{ |
116
|
5 |
|
return $this->code; |
117
|
|
|
} |
118
|
|
|
} |
119
|
|
|
|
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.