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 | * sets the FQDN of the API |
||
56 | * |
||
57 | * @param string $host FQDN |
||
58 | * |
||
59 | * @return void |
||
60 | */ |
||
61 | 3 | public function setHost($host) |
|
65 | |||
66 | /** |
||
67 | * get the FQDN of the API |
||
68 | * |
||
69 | * @return string FQDN |
||
70 | */ |
||
71 | 3 | public function getHost() |
|
75 | |||
76 | /** |
||
77 | * set the origin service definition |
||
78 | * |
||
79 | * @param mixed $origin the origin service definition (type depends on dispersal strategy) |
||
80 | * |
||
81 | * @return void |
||
82 | */ |
||
83 | 1 | public function setOrigin($origin) |
|
87 | |||
88 | /** |
||
89 | * get the origin service definition |
||
90 | * |
||
91 | * @return mixed the origin service definition (type depends on dispersal strategy) |
||
92 | */ |
||
93 | public function getOrigin() |
||
97 | |||
98 | /** |
||
99 | * add an endpoint |
||
100 | * |
||
101 | * @param string $endpoint endpoint |
||
102 | * |
||
103 | * @return void |
||
104 | */ |
||
105 | 3 | public function addEndpoint($endpoint) |
|
109 | |||
110 | /** |
||
111 | * check if an endpoint exists |
||
112 | * |
||
113 | * @param string $endpoint endpoint |
||
114 | * |
||
115 | * @return boolean |
||
116 | */ |
||
117 | 2 | public function hasEndpoint($endpoint) |
|
126 | |||
127 | /** |
||
128 | * get all defined API endpoints |
||
129 | * |
||
130 | * @param boolean $withHost url with hostname |
||
131 | * @param string $prefix add a prefix to the url (blub/endpoint/url) |
||
132 | * |
||
133 | * @return array |
||
134 | */ |
||
135 | 3 | public function getEndpoints($withHost = true, $prefix = null) |
|
154 | |||
155 | /** |
||
156 | * add a schema for an endpoint |
||
157 | * |
||
158 | * @param string $endpoint endpoint |
||
159 | * @param \stdClass $schema schema |
||
160 | * |
||
161 | * @return void |
||
162 | */ |
||
163 | 2 | public function addSchema($endpoint, $schema) |
|
167 | |||
168 | /** |
||
169 | * get a schema for an endpoint |
||
170 | * |
||
171 | * @param string $endpoint endpoint |
||
172 | * |
||
173 | * @return \stdClass |
||
174 | */ |
||
175 | 1 | public function getSchema($endpoint) |
|
188 | } |
||
189 |