1 | <?php |
||
9 | class Operation implements ToArrayInterface |
||
10 | { |
||
11 | /** @var array Parameters */ |
||
12 | private $parameters = []; |
||
13 | |||
14 | /** @var Parameter Additional parameters schema */ |
||
15 | private $additionalParameters; |
||
16 | |||
17 | /** @var DescriptionInterface */ |
||
18 | private $description; |
||
19 | |||
20 | /** @var array Config data */ |
||
21 | private $config; |
||
22 | |||
23 | /** |
||
24 | * Builds an Operation object using an array of configuration data. |
||
25 | * |
||
26 | * - name: (string) Name of the command |
||
27 | * - httpMethod: (string) HTTP method of the operation |
||
28 | * - uri: (string) URI template that can create a relative or absolute URL |
||
29 | * - parameters: (array) Associative array of parameters for the command. |
||
30 | * Each value must be an array that is used to create {@see Parameter} |
||
31 | * objects. |
||
32 | * - summary: (string) This is a short summary of what the operation does |
||
33 | * - notes: (string) A longer description of the operation. |
||
34 | * - documentationUrl: (string) Reference URL providing more information |
||
35 | * about the operation. |
||
36 | * - responseModel: (string) The model name used for processing response. |
||
37 | * - deprecated: (bool) Set to true if this is a deprecated command |
||
38 | * - errorResponses: (array) Errors that could occur when executing the |
||
39 | * command. Array of hashes, each with a 'code' (the HTTP response code), |
||
40 | * 'phrase' (response reason phrase or description of the error), and |
||
41 | * 'class' (a custom exception class that would be thrown if the error is |
||
42 | * encountered). |
||
43 | * - data: (array) Any extra data that might be used to help build or |
||
44 | * serialize the operation |
||
45 | * - additionalParameters: (null|array) Parameter schema to use when an |
||
46 | * option is passed to the operation that is not in the schema |
||
47 | * |
||
48 | * @param array $config Array of configuration data |
||
49 | * @param DescriptionInterface $description Service description used to resolve models if $ref tags are found |
||
50 | * @throws \InvalidArgumentException |
||
51 | */ |
||
52 | 10 | public function __construct(array $config = [], DescriptionInterface $description = null) |
|
84 | |||
85 | /** |
||
86 | * @return array |
||
87 | */ |
||
88 | 1 | public function toArray() |
|
92 | |||
93 | /** |
||
94 | * Get the service description that the operation belongs to |
||
95 | * |
||
96 | * @return Description |
||
97 | */ |
||
98 | 1 | public function getServiceDescription() |
|
102 | |||
103 | /** |
||
104 | * Get the params of the operation |
||
105 | * |
||
106 | * @return Parameter[] |
||
107 | */ |
||
108 | 1 | public function getParams() |
|
112 | |||
113 | /** |
||
114 | * Get additionalParameters of the operation |
||
115 | * |
||
116 | * @return Parameter|null |
||
117 | */ |
||
118 | 1 | public function getAdditionalParameters() |
|
122 | |||
123 | /** |
||
124 | * Check if the operation has a specific parameter by name |
||
125 | * |
||
126 | * @param string $name Name of the param |
||
127 | * |
||
128 | * @return bool |
||
129 | */ |
||
130 | 2 | public function hasParam($name) |
|
134 | |||
135 | /** |
||
136 | * Get a single parameter of the operation |
||
137 | * |
||
138 | * @param string $name Parameter to retrieve by name |
||
139 | * |
||
140 | * @return Parameter|null |
||
141 | */ |
||
142 | 3 | public function getParam($name) |
|
148 | |||
149 | /** |
||
150 | * Get the HTTP method of the operation |
||
151 | * |
||
152 | * @return string|null |
||
153 | */ |
||
154 | 1 | public function getHttpMethod() |
|
158 | |||
159 | /** |
||
160 | * Get the name of the operation |
||
161 | * |
||
162 | * @return string|null |
||
163 | */ |
||
164 | 1 | public function getName() |
|
168 | |||
169 | /** |
||
170 | * Get a short summary of what the operation does |
||
171 | * |
||
172 | * @return string|null |
||
173 | */ |
||
174 | 2 | public function getSummary() |
|
178 | |||
179 | /** |
||
180 | * Get a longer text field to explain the behavior of the operation |
||
181 | * |
||
182 | * @return string|null |
||
183 | */ |
||
184 | 1 | public function getNotes() |
|
188 | |||
189 | /** |
||
190 | * Get the documentation URL of the operation |
||
191 | * |
||
192 | * @return string|null |
||
193 | */ |
||
194 | 1 | public function getDocumentationUrl() |
|
198 | |||
199 | /** |
||
200 | * Get the name of the model used for processing the response. |
||
201 | * |
||
202 | * @return string |
||
203 | */ |
||
204 | 1 | public function getResponseModel() |
|
208 | |||
209 | /** |
||
210 | * Get whether or not the operation is deprecated |
||
211 | * |
||
212 | * @return bool |
||
213 | */ |
||
214 | 1 | public function getDeprecated() |
|
218 | |||
219 | /** |
||
220 | * Get the URI that will be merged into the generated request |
||
221 | * |
||
222 | * @return string |
||
223 | */ |
||
224 | 1 | public function getUri() |
|
228 | |||
229 | /** |
||
230 | * Get the errors that could be encountered when executing the operation |
||
231 | * |
||
232 | * @return array |
||
233 | */ |
||
234 | 1 | public function getErrorResponses() |
|
238 | |||
239 | /** |
||
240 | * Get extra data from the operation |
||
241 | * |
||
242 | * @param string $name Name of the data point to retrieve or null to |
||
243 | * retrieve all of the extra data. |
||
244 | * |
||
245 | * @return mixed|null |
||
246 | */ |
||
247 | 1 | public function getData($name = null) |
|
257 | |||
258 | /** |
||
259 | * @param $name |
||
260 | * @param array $config |
||
261 | * @return array |
||
262 | */ |
||
263 | 1 | private function resolveExtends($name, array $config) |
|
279 | |||
280 | /** |
||
281 | * Process the description and extract the parameter config |
||
282 | * |
||
283 | * @return void |
||
284 | */ |
||
285 | 10 | private function resolveParameters() |
|
312 | } |
||
313 |