|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* AppserverIo\RestApi\Wrappers\OA2\OperationWrapper |
|
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 2018 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/restapi |
|
18
|
|
|
* @link http://www.appserver.io |
|
19
|
|
|
*/ |
|
20
|
|
|
|
|
21
|
|
|
namespace AppserverIo\RestApi\Wrappers\OA2; |
|
22
|
|
|
|
|
23
|
|
|
use Swagger\Annotations\Parameter; |
|
24
|
|
|
use AppserverIo\RestApi\Wrappers\ParameterWrapperInterface; |
|
25
|
|
|
|
|
26
|
|
|
/** |
|
27
|
|
|
* The wrapper implementation for a parameter wrapper. |
|
28
|
|
|
* |
|
29
|
|
|
* @author Tim Wagner <[email protected]> |
|
30
|
|
|
* @copyright 2018 TechDivision GmbH <[email protected]> |
|
31
|
|
|
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) |
|
32
|
|
|
* @link https://github.com/appserver-io/restapi |
|
33
|
|
|
* @link http://www.appserver.io |
|
34
|
|
|
*/ |
|
35
|
|
|
class ParameterWrapper implements ParameterWrapperInterface |
|
36
|
|
|
{ |
|
37
|
|
|
|
|
38
|
|
|
/** |
|
39
|
|
|
* The parameter to be wrapped. |
|
40
|
|
|
* |
|
41
|
|
|
* @var \Swagger\Annotations\Parameter |
|
42
|
|
|
*/ |
|
43
|
|
|
protected $parameter; |
|
44
|
|
|
|
|
45
|
|
|
/** |
|
46
|
|
|
* Initializes the instance with the parameter that has to be wrapped. |
|
47
|
|
|
* |
|
48
|
|
|
* @param \Swagger\Annotations\Parameter $parameter The parameter |
|
49
|
|
|
*/ |
|
50
|
|
|
public function __construct(Parameter $parameter) |
|
51
|
|
|
{ |
|
52
|
|
|
$this->parameter = $parameter; |
|
53
|
|
|
} |
|
54
|
|
|
|
|
55
|
|
|
/** |
|
56
|
|
|
* Returns the wrapped parameter instance. |
|
57
|
|
|
* |
|
58
|
|
|
* @return \Swagger\Annotations\Parameter |
|
59
|
|
|
*/ |
|
60
|
|
|
protected function getParameter() |
|
61
|
|
|
{ |
|
62
|
|
|
return $this->parameter; |
|
63
|
|
|
} |
|
64
|
|
|
|
|
65
|
|
|
/** |
|
66
|
|
|
* Query whether or not the parameter is in the passed scope. |
|
67
|
|
|
* |
|
68
|
|
|
* @param string $in The scope to query |
|
69
|
|
|
* |
|
70
|
|
|
* @return boolean TRUE if the scope matches, else FALSE |
|
71
|
|
|
*/ |
|
72
|
|
|
public function isIn($in) |
|
73
|
|
|
{ |
|
74
|
|
|
return strcasecmp($this->getIn(), $in) === 0 ? true : false; |
|
75
|
|
|
} |
|
76
|
|
|
|
|
77
|
|
|
/** |
|
78
|
|
|
* Returns the location of the parameter. |
|
79
|
|
|
* |
|
80
|
|
|
* @return string The location of the parameter |
|
81
|
|
|
*/ |
|
82
|
|
|
public function getIn() |
|
83
|
|
|
{ |
|
84
|
|
|
return $this->getParameter()->in; |
|
85
|
|
|
} |
|
86
|
|
|
|
|
87
|
|
|
/** |
|
88
|
|
|
* Returns the type of the parameter. |
|
89
|
|
|
* |
|
90
|
|
|
* @return string The parameter type |
|
91
|
|
|
*/ |
|
92
|
|
|
public function getType() |
|
93
|
|
|
{ |
|
94
|
|
|
return $this->getParameter()->type; |
|
95
|
|
|
} |
|
96
|
|
|
|
|
97
|
|
|
/** |
|
98
|
|
|
* Returns the parameter's name. |
|
99
|
|
|
* |
|
100
|
|
|
* @return string The name |
|
101
|
|
|
*/ |
|
102
|
|
|
public function getName() |
|
103
|
|
|
{ |
|
104
|
|
|
return $this->getParameter()->name; |
|
105
|
|
|
} |
|
106
|
|
|
|
|
107
|
|
|
/** |
|
108
|
|
|
* Returns the parameter's collection format. |
|
109
|
|
|
* |
|
110
|
|
|
* @return string The collection format |
|
111
|
|
|
*/ |
|
112
|
|
|
public function getCollectionFormat() |
|
113
|
|
|
{ |
|
114
|
|
|
return $this->getParameter()->collectionFormat; |
|
115
|
|
|
} |
|
116
|
|
|
|
|
117
|
|
|
/** |
|
118
|
|
|
* Query whether or not the parameter has the passed collection format. |
|
119
|
|
|
* |
|
120
|
|
|
* @param string $collectionFormat The collection format to query |
|
121
|
|
|
* |
|
122
|
|
|
* @return boolean TRUE if collection format matches, else FALSE |
|
123
|
|
|
*/ |
|
124
|
|
|
public function hasCollectionFormat($collectionFormat) |
|
125
|
|
|
{ |
|
126
|
|
|
return strcasecmp($this->getCollectionFormat(), $collectionFormat) === 0 ? true : false; |
|
127
|
|
|
} |
|
128
|
|
|
} |
|
129
|
|
|
|