|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* Copyright (C) 2013-2016 |
|
4
|
|
|
* Piotr Olaszewski <[email protected]> |
|
5
|
|
|
* |
|
6
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a copy |
|
7
|
|
|
* of this software and associated documentation files (the "Software"), to deal |
|
8
|
|
|
* in the Software without restriction, including without limitation the rights |
|
9
|
|
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
|
10
|
|
|
* copies of the Software, and to permit persons to whom the Software is |
|
11
|
|
|
* furnished to do so, subject to the following conditions: |
|
12
|
|
|
* |
|
13
|
|
|
* The above copyright notice and this permission notice shall be included in |
|
14
|
|
|
* all copies or substantial portions of the Software. |
|
15
|
|
|
* |
|
16
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
|
17
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
|
18
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
|
19
|
|
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
|
20
|
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
|
21
|
|
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
|
22
|
|
|
* SOFTWARE. |
|
23
|
|
|
*/ |
|
24
|
|
|
namespace WSDL\Builder; |
|
25
|
|
|
|
|
26
|
|
|
use InvalidArgumentException; |
|
27
|
|
|
use WSDL\Annotation\BindingType; |
|
28
|
|
|
use WSDL\Annotation\SoapBinding; |
|
29
|
|
|
|
|
30
|
|
|
/** |
|
31
|
|
|
* WSDLBuilder |
|
32
|
|
|
* |
|
33
|
|
|
* @author Piotr Olaszewski <[email protected]> |
|
34
|
|
|
*/ |
|
35
|
|
|
class WSDLBuilder |
|
36
|
|
|
{ |
|
37
|
|
|
/** |
|
38
|
|
|
* @var string |
|
39
|
|
|
*/ |
|
40
|
|
|
private $name; |
|
41
|
|
|
/** |
|
42
|
|
|
* @var string |
|
43
|
|
|
*/ |
|
44
|
|
|
private $targetNamespace; |
|
45
|
|
|
/** |
|
46
|
|
|
* @var string |
|
47
|
|
|
*/ |
|
48
|
|
|
private $ns; |
|
49
|
|
|
/** |
|
50
|
|
|
* @var string |
|
51
|
|
|
*/ |
|
52
|
|
|
private $location; |
|
53
|
|
|
/** |
|
54
|
|
|
* @var string |
|
55
|
|
|
*/ |
|
56
|
|
|
private $style = SoapBinding::RPC; |
|
57
|
|
|
/** |
|
58
|
|
|
* @var string |
|
59
|
|
|
*/ |
|
60
|
|
|
private $use = SoapBinding::LITERAL; |
|
61
|
|
|
/** |
|
62
|
|
|
* @var string |
|
63
|
|
|
*/ |
|
64
|
|
|
private $parameterStyle = SoapBinding::BARE; |
|
65
|
|
|
/** |
|
66
|
|
|
* @var string |
|
67
|
|
|
*/ |
|
68
|
|
|
private $soapVersion = BindingType::SOAP_11; |
|
69
|
|
|
/** |
|
70
|
|
|
* @var Method[] |
|
71
|
|
|
*/ |
|
72
|
|
|
private $methods; |
|
73
|
|
|
|
|
74
|
|
|
/** |
|
75
|
|
|
* @return WSDLBuilder |
|
76
|
|
|
*/ |
|
77
|
10 |
|
public static function instance() |
|
78
|
|
|
{ |
|
79
|
10 |
|
return new self(); |
|
80
|
|
|
} |
|
81
|
|
|
|
|
82
|
|
|
/** |
|
83
|
|
|
* @return string |
|
84
|
|
|
*/ |
|
85
|
1 |
|
public function getName() |
|
86
|
|
|
{ |
|
87
|
1 |
|
return $this->name; |
|
88
|
|
|
} |
|
89
|
|
|
|
|
90
|
|
|
/** |
|
91
|
|
|
* @param string $name |
|
92
|
|
|
* @return $this |
|
93
|
|
|
* @throws InvalidArgumentException |
|
94
|
|
|
*/ |
|
95
|
4 |
|
public function setName($name) |
|
96
|
|
|
{ |
|
97
|
4 |
|
IsValid::notEmpty($name, 'Name cannot be empty'); |
|
98
|
3 |
|
$this->name = $name; |
|
99
|
3 |
|
return $this; |
|
100
|
|
|
} |
|
101
|
|
|
|
|
102
|
|
|
/** |
|
103
|
|
|
* @return string |
|
104
|
|
|
*/ |
|
105
|
1 |
|
public function getTargetNamespace() |
|
106
|
|
|
{ |
|
107
|
1 |
|
return $this->targetNamespace; |
|
108
|
|
|
} |
|
109
|
|
|
|
|
110
|
|
|
/** |
|
111
|
|
|
* @param string $targetNamespace |
|
112
|
|
|
* @return $this |
|
113
|
|
|
* @throws InvalidArgumentException |
|
114
|
|
|
*/ |
|
115
|
4 |
|
public function setTargetNamespace($targetNamespace) |
|
116
|
|
|
{ |
|
117
|
4 |
|
IsValid::notEmpty($targetNamespace, 'Target namespace cannot be empty'); |
|
118
|
3 |
|
$this->targetNamespace = $targetNamespace; |
|
119
|
3 |
|
return $this; |
|
120
|
|
|
} |
|
121
|
|
|
|
|
122
|
|
|
/** |
|
123
|
|
|
* @return string |
|
124
|
|
|
*/ |
|
125
|
1 |
|
public function getNs() |
|
126
|
|
|
{ |
|
127
|
1 |
|
return $this->ns; |
|
128
|
|
|
} |
|
129
|
|
|
|
|
130
|
|
|
/** |
|
131
|
|
|
* @param string $ns |
|
132
|
|
|
* @return $this |
|
133
|
|
|
* @throws InvalidArgumentException |
|
134
|
|
|
*/ |
|
135
|
4 |
|
public function setNs($ns) |
|
136
|
|
|
{ |
|
137
|
4 |
|
IsValid::notEmpty($ns, 'NS cannot be empty'); |
|
138
|
3 |
|
$this->ns = $ns; |
|
139
|
3 |
|
return $this; |
|
140
|
|
|
} |
|
141
|
|
|
|
|
142
|
|
|
/** |
|
143
|
|
|
* @return string |
|
144
|
|
|
*/ |
|
145
|
1 |
|
public function getLocation() |
|
146
|
|
|
{ |
|
147
|
1 |
|
return $this->location; |
|
148
|
|
|
} |
|
149
|
|
|
|
|
150
|
|
|
/** |
|
151
|
|
|
* @param string $location |
|
152
|
|
|
* @return $this |
|
153
|
|
|
* @throws InvalidArgumentException |
|
154
|
|
|
*/ |
|
155
|
4 |
|
public function setLocation($location) |
|
156
|
|
|
{ |
|
157
|
4 |
|
IsValid::notEmpty($location, 'Location cannot be empty'); |
|
158
|
3 |
|
$this->location = $location; |
|
159
|
3 |
|
return $this; |
|
160
|
|
|
} |
|
161
|
|
|
|
|
162
|
|
|
/** |
|
163
|
|
|
* @return string |
|
164
|
|
|
*/ |
|
165
|
1 |
|
public function getStyle() |
|
166
|
|
|
{ |
|
167
|
1 |
|
return $this->style; |
|
168
|
|
|
} |
|
169
|
|
|
|
|
170
|
|
|
/** |
|
171
|
|
|
* @param string $style |
|
172
|
|
|
* @return $this |
|
173
|
|
|
* @throws InvalidArgumentException |
|
174
|
|
|
*/ |
|
175
|
4 |
|
public function setStyle($style) |
|
176
|
|
|
{ |
|
177
|
4 |
|
IsValid::style($style); |
|
178
|
3 |
|
$this->style = $style; |
|
179
|
3 |
|
return $this; |
|
180
|
|
|
} |
|
181
|
|
|
|
|
182
|
|
|
/** |
|
183
|
|
|
* @return string |
|
184
|
|
|
*/ |
|
185
|
1 |
|
public function getUse() |
|
186
|
|
|
{ |
|
187
|
1 |
|
return $this->use; |
|
188
|
|
|
} |
|
189
|
|
|
|
|
190
|
|
|
/** |
|
191
|
|
|
* @param string $use |
|
192
|
|
|
* @return $this |
|
193
|
|
|
*/ |
|
194
|
4 |
|
public function setUse($use) |
|
195
|
|
|
{ |
|
196
|
4 |
|
IsValid::useStyle($use); |
|
197
|
3 |
|
$this->use = $use; |
|
198
|
3 |
|
return $this; |
|
199
|
|
|
} |
|
200
|
|
|
|
|
201
|
|
|
/** |
|
202
|
|
|
* @return string |
|
203
|
|
|
*/ |
|
204
|
1 |
|
public function getParameterStyle() |
|
205
|
|
|
{ |
|
206
|
1 |
|
return $this->parameterStyle; |
|
207
|
|
|
} |
|
208
|
|
|
|
|
209
|
|
|
/** |
|
210
|
|
|
* @param string $parameterStyle |
|
211
|
|
|
* @return $this |
|
212
|
|
|
*/ |
|
213
|
3 |
|
public function setParameterStyle($parameterStyle) |
|
214
|
|
|
{ |
|
215
|
3 |
|
$this->parameterStyle = $parameterStyle; |
|
216
|
3 |
|
return $this; |
|
217
|
|
|
} |
|
218
|
|
|
|
|
219
|
|
|
/** |
|
220
|
|
|
* @return string |
|
221
|
|
|
*/ |
|
222
|
1 |
|
public function getSoapVersion() |
|
223
|
|
|
{ |
|
224
|
1 |
|
return $this->soapVersion; |
|
225
|
|
|
} |
|
226
|
|
|
|
|
227
|
|
|
/** |
|
228
|
|
|
* @param string $soapVersion |
|
229
|
|
|
* @return $this |
|
230
|
|
|
* @throws InvalidArgumentException |
|
231
|
|
|
*/ |
|
232
|
4 |
|
public function setSoapVersion($soapVersion) |
|
233
|
|
|
{ |
|
234
|
4 |
|
IsValid::soapVersion($soapVersion); |
|
235
|
3 |
|
$this->soapVersion = $soapVersion; |
|
236
|
3 |
|
return $this; |
|
237
|
|
|
} |
|
238
|
|
|
|
|
239
|
|
|
/** |
|
240
|
|
|
* @return Method[] |
|
241
|
|
|
*/ |
|
242
|
|
|
public function getMethods() |
|
243
|
|
|
{ |
|
244
|
|
|
return $this->methods; |
|
245
|
|
|
} |
|
246
|
|
|
|
|
247
|
|
|
/** |
|
248
|
|
|
* @param Method $method |
|
249
|
|
|
* @return $this |
|
250
|
|
|
*/ |
|
251
|
|
|
public function setMethod(Method $method) |
|
252
|
|
|
{ |
|
253
|
|
|
$this->methods[] = $method; |
|
254
|
|
|
return $this; |
|
255
|
|
|
} |
|
256
|
|
|
} |
|
257
|
|
|
|