1 | <?php |
||
9 | class Description implements DescriptionInterface |
||
10 | { |
||
11 | /** @var array Array of {@see OperationInterface} objects */ |
||
12 | private $operations = []; |
||
13 | |||
14 | /** @var array Array of API models */ |
||
15 | private $models = []; |
||
16 | |||
17 | /** @var string Name of the API */ |
||
18 | private $name; |
||
19 | |||
20 | /** @var string API version */ |
||
21 | private $apiVersion; |
||
22 | |||
23 | /** @var string Summary of the API */ |
||
24 | private $description; |
||
25 | |||
26 | /** @var array Any extra API data */ |
||
27 | private $extraData = []; |
||
28 | |||
29 | /** @var Uri baseUri/basePath */ |
||
30 | private $baseUri; |
||
31 | |||
32 | /** @var SchemaFormatter */ |
||
33 | private $formatter; |
||
34 | |||
35 | /** |
||
36 | * @param array $config Service description data |
||
37 | * @param array $options Custom options to apply to the description |
||
38 | * - formatter: Can provide a custom SchemaFormatter class |
||
39 | * |
||
40 | * @throws \InvalidArgumentException |
||
41 | */ |
||
42 | 14 | public function __construct(array $config, array $options = []) |
|
96 | |||
97 | /** |
||
98 | * Get the basePath/baseUri of the description |
||
99 | * |
||
100 | * @return Uri |
||
101 | */ |
||
102 | 2 | public function getBaseUri() |
|
106 | |||
107 | /** |
||
108 | * Get the API operations of the service |
||
109 | * |
||
110 | * @return Operation[] Returns an array of {@see Operation} objects |
||
111 | */ |
||
112 | 1 | public function getOperations() |
|
116 | |||
117 | /** |
||
118 | * Check if the service has an operation by name |
||
119 | * |
||
120 | * @param string $name Name of the operation to check |
||
121 | * |
||
122 | * @return bool |
||
123 | */ |
||
124 | 4 | public function hasOperation($name) |
|
128 | |||
129 | /** |
||
130 | * Get an API operation by name |
||
131 | * |
||
132 | * @param string $name Name of the command |
||
133 | * |
||
134 | * @return Operation |
||
135 | * @throws \InvalidArgumentException if the operation is not found |
||
136 | */ |
||
137 | 3 | public function getOperation($name) |
|
151 | |||
152 | /** |
||
153 | * Get a shared definition structure. |
||
154 | * |
||
155 | * @param string $id ID/name of the model to retrieve |
||
156 | * |
||
157 | * @return Parameter |
||
158 | * @throws \InvalidArgumentException if the model is not found |
||
159 | */ |
||
160 | 3 | public function getModel($id) |
|
176 | |||
177 | /** |
||
178 | * Get all models of the service description. |
||
179 | * |
||
180 | * @return array |
||
181 | */ |
||
182 | 1 | public function getModels() |
|
191 | |||
192 | /** |
||
193 | * Check if the service description has a model by name. |
||
194 | * |
||
195 | * @param string $id Name/ID of the model to check |
||
196 | * |
||
197 | * @return bool |
||
198 | */ |
||
199 | 3 | public function hasModel($id) |
|
203 | |||
204 | /** |
||
205 | * Get the API version of the service |
||
206 | * |
||
207 | * @return string |
||
208 | */ |
||
209 | 1 | public function getApiVersion() |
|
213 | |||
214 | /** |
||
215 | * Get the name of the API |
||
216 | * |
||
217 | * @return string |
||
218 | */ |
||
219 | 1 | public function getName() |
|
223 | |||
224 | /** |
||
225 | * Get a summary of the purpose of the API |
||
226 | * |
||
227 | * @return string |
||
228 | */ |
||
229 | 1 | public function getDescription() |
|
233 | |||
234 | /** |
||
235 | * Format a parameter using named formats. |
||
236 | * |
||
237 | * @param string $format Format to convert it to |
||
238 | * @param mixed $input Input string |
||
239 | * |
||
240 | * @return mixed |
||
241 | */ |
||
242 | 2 | public function format($format, $input) |
|
246 | |||
247 | /** |
||
248 | * Get arbitrary data from the service description that is not part of the |
||
249 | * Guzzle service description specification. |
||
250 | * |
||
251 | * @param string $key Data key to retrieve or null to retrieve all extra |
||
252 | * |
||
253 | * @return null|mixed |
||
254 | */ |
||
255 | 1 | public function getData($key = null) |
|
265 | } |
||
266 |