1 | <?php |
||
15 | class ApiDefinition |
||
16 | { |
||
17 | /** |
||
18 | * @var string |
||
19 | */ |
||
20 | private $basePath; |
||
21 | |||
22 | /** |
||
23 | * @var string |
||
24 | */ |
||
25 | private $host; |
||
26 | |||
27 | /** |
||
28 | * @var mixed |
||
29 | */ |
||
30 | private $origin; |
||
31 | |||
32 | /** |
||
33 | * @var array |
||
34 | */ |
||
35 | private $endpoints = array(); |
||
36 | |||
37 | /** |
||
38 | * @var array |
||
39 | */ |
||
40 | private $schemes = array(); |
||
41 | |||
42 | /** |
||
43 | * sets the base path of the api |
||
44 | * |
||
45 | * @param string $basePath API base path |
||
46 | * |
||
47 | * @return void |
||
48 | */ |
||
49 | 1 | public function setBasePath($basePath) |
|
53 | |||
54 | /** |
||
55 | * Gets the API's base path |
||
56 | * |
||
57 | * @return string The base path |
||
58 | */ |
||
59 | public function getBasePath() |
||
63 | 3 | ||
64 | 3 | /** |
|
65 | * sets the FQDN of the API |
||
66 | * |
||
67 | * @param string $host FQDN |
||
68 | * |
||
69 | * @return void |
||
70 | */ |
||
71 | 3 | public function setHost($host) |
|
75 | |||
76 | /** |
||
77 | * get the FQDN of the API |
||
78 | * |
||
79 | * @return string FQDN |
||
80 | */ |
||
81 | public function getHost() |
||
85 | 1 | ||
86 | 1 | /** |
|
87 | * set the origin service definition |
||
88 | * |
||
89 | * @param mixed $origin the origin service definition (type depends on dispersal strategy) |
||
90 | * |
||
91 | * @return void |
||
92 | */ |
||
93 | public function setOrigin($origin) |
||
97 | |||
98 | /** |
||
99 | * get the origin service definition |
||
100 | * |
||
101 | * @return mixed the origin service definition (type depends on dispersal strategy) |
||
102 | */ |
||
103 | public function getOrigin() |
||
107 | 3 | ||
108 | 3 | /** |
|
109 | * add an endpoint |
||
110 | * |
||
111 | * @param string $endpoint endpoint |
||
112 | * |
||
113 | * @return void |
||
114 | */ |
||
115 | public function addEndpoint($endpoint) |
||
119 | 2 | ||
120 | 2 | /** |
|
121 | 2 | * check if an endpoint exists |
|
122 | 2 | * |
|
123 | * @param string $endpoint endpoint |
||
124 | 2 | * |
|
125 | * @return boolean |
||
126 | */ |
||
127 | public function hasEndpoint($endpoint) |
||
128 | { |
||
129 | $retVal = false; |
||
130 | if (isset($this->endpoints)) { |
||
131 | $retVal = in_array($endpoint, $this->endpoints); |
||
132 | } |
||
133 | |||
134 | return $retVal; |
||
135 | 3 | } |
|
136 | |||
137 | 3 | /** |
|
138 | 3 | * get all defined API endpoints |
|
139 | 3 | * |
|
140 | 2 | * @param boolean $withHost url with hostname |
|
141 | 2 | * @param string $prefix add a prefix to the url (blub/endpoint/url) |
|
142 | 3 | * @param string $host Host to be used instead of the host defined in the swagger json |
|
143 | 1 | * @param bool $withBasePath Defines whether the API's base path should be included or not |
|
144 | 1 | * |
|
145 | 3 | * @return array |
|
146 | 1 | */ |
|
147 | 1 | public function getEndpoints($withHost = true, $prefix = null, $host = '', $withBasePath = true) |
|
166 | 2 | ||
167 | /** |
||
168 | * add a schema for an endpoint |
||
169 | * |
||
170 | * @param string $endpoint endpoint |
||
171 | * @param \stdClass $schema schema |
||
172 | * |
||
173 | * @return void |
||
174 | */ |
||
175 | 1 | public function addSchema($endpoint, $schema) |
|
179 | 1 | ||
180 | 1 | /** |
|
181 | 1 | * get a schema for an endpoint |
|
182 | 1 | * |
|
183 | 1 | * @param string $endpoint endpoint |
|
184 | 1 | * |
|
185 | * @return \stdClass |
||
186 | 1 | */ |
|
187 | public function getSchema($endpoint) |
||
200 | } |
||
201 |