1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* AppserverIo\Routlt\Annotations\Action |
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
|
|
|
/** |
24
|
|
|
* Annotation to map a request path info to an action method. |
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 http://github.com/appserver-io/routlt |
30
|
|
|
* @link http://www.appserver.io |
31
|
|
|
* |
32
|
|
|
* @Annotation |
33
|
|
|
* @Target({"METHOD"}) |
34
|
|
|
*/ |
35
|
|
|
class Action |
36
|
|
|
{ |
37
|
|
|
|
38
|
|
|
/** |
39
|
|
|
* The value of the name attribute. |
40
|
|
|
* |
41
|
|
|
* @var string |
42
|
|
|
*/ |
43
|
|
|
protected $name; |
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* The value of the restrictions attribute. |
47
|
|
|
* |
48
|
|
|
* @var string |
49
|
|
|
*/ |
50
|
|
|
protected $restrictions; |
51
|
|
|
|
52
|
|
|
/** |
53
|
|
|
* The value of the defaults attribute. |
54
|
|
|
* |
55
|
|
|
* @var string |
56
|
|
|
*/ |
57
|
|
|
protected $defaults; |
58
|
|
|
|
59
|
|
|
/** |
60
|
|
|
* The constructor the initializes the instance with the |
61
|
|
|
* data passed with the token. |
62
|
|
|
* |
63
|
|
|
* @param array $values The annotation values |
64
|
|
|
*/ |
65
|
9 |
View Code Duplication |
public function __construct(array $values = array()) |
|
|
|
|
66
|
|
|
{ |
67
|
|
|
|
68
|
|
|
// set the name attribute, if available |
69
|
9 |
|
if (isset($values[AnnotationKeys::NAME])) { |
70
|
8 |
|
$this->name = $values[AnnotationKeys::NAME]; |
71
|
8 |
|
} |
72
|
|
|
|
73
|
|
|
// set the restrictions attribute, if available |
74
|
9 |
|
if (isset($values[AnnotationKeys::RESTRICTIONS])) { |
75
|
|
|
$this->restrictions = $values[AnnotationKeys::RESTRICTIONS]; |
76
|
|
|
} |
77
|
|
|
|
78
|
|
|
// set the defaults attribute, if available |
79
|
9 |
|
if (isset($values[AnnotationKeys::DEFAULTS])) { |
80
|
|
|
$this->defaults = $values[AnnotationKeys::DEFAULTS]; |
81
|
|
|
} |
82
|
9 |
|
} |
83
|
|
|
|
84
|
|
|
/** |
85
|
|
|
* Returns the value of the name attribute. |
86
|
|
|
* |
87
|
|
|
* @return string|null The annotations name attribute |
88
|
|
|
*/ |
89
|
9 |
|
public function getName() |
90
|
|
|
{ |
91
|
9 |
|
return $this->name; |
92
|
|
|
} |
93
|
|
|
|
94
|
|
|
/** |
95
|
|
|
* Returns the value of the restrictions attribute. |
96
|
|
|
* |
97
|
|
|
* @return string|null The annotations restrictions attribute |
98
|
|
|
*/ |
99
|
8 |
|
public function getRestrictions() |
100
|
|
|
{ |
101
|
8 |
|
return $this->restrictions; |
102
|
|
|
} |
103
|
|
|
|
104
|
|
|
/** |
105
|
|
|
* Returns the value of the defaults attribute. |
106
|
|
|
* |
107
|
|
|
* @return string|null The annotations defaults attribute |
108
|
|
|
*/ |
109
|
8 |
|
public function getDefaults() |
110
|
|
|
{ |
111
|
8 |
|
return $this->defaults; |
112
|
|
|
} |
113
|
|
|
} |
114
|
|
|
|
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.