|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* Copyright (C) 2013-2018 |
|
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 WSDL\Annotation\BindingType; |
|
27
|
|
|
use WSDL\Annotation\SoapBinding; |
|
28
|
|
|
|
|
29
|
|
|
/** |
|
30
|
|
|
* WSDLBuilder |
|
31
|
|
|
* |
|
32
|
|
|
* @author Piotr Olaszewski <[email protected]> |
|
33
|
|
|
*/ |
|
34
|
|
|
class WSDLBuilder |
|
35
|
|
|
{ |
|
36
|
|
|
/** |
|
37
|
|
|
* @var string |
|
38
|
|
|
*/ |
|
39
|
|
|
private $name; |
|
40
|
|
|
/** |
|
41
|
|
|
* @var string |
|
42
|
|
|
*/ |
|
43
|
|
|
private $targetNamespace; |
|
44
|
|
|
/** |
|
45
|
|
|
* @var string |
|
46
|
|
|
*/ |
|
47
|
|
|
private $ns; |
|
48
|
|
|
/** |
|
49
|
|
|
* @var string |
|
50
|
|
|
*/ |
|
51
|
|
|
private $location; |
|
52
|
|
|
/** |
|
53
|
|
|
* @var string |
|
54
|
|
|
*/ |
|
55
|
|
|
private $style = SoapBinding::RPC; |
|
56
|
|
|
/** |
|
57
|
|
|
* @var string |
|
58
|
|
|
*/ |
|
59
|
|
|
private $use = SoapBinding::LITERAL; |
|
60
|
|
|
/** |
|
61
|
|
|
* @var string |
|
62
|
|
|
*/ |
|
63
|
|
|
private $parameterStyle = SoapBinding::BARE; |
|
64
|
|
|
/** |
|
65
|
|
|
* @var string |
|
66
|
|
|
*/ |
|
67
|
|
|
private $soapVersion = BindingType::SOAP_11; |
|
68
|
|
|
/** |
|
69
|
|
|
* @var Method[] |
|
70
|
|
|
*/ |
|
71
|
|
|
private $methods; |
|
72
|
|
|
/** |
|
73
|
|
|
* @var string |
|
74
|
|
|
*/ |
|
75
|
|
|
private $portName; |
|
76
|
|
|
|
|
77
|
17 |
|
public static function instance(): WSDLBuilder |
|
78
|
|
|
{ |
|
79
|
17 |
|
return new self(); |
|
80
|
|
|
} |
|
81
|
|
|
|
|
82
|
|
|
public function getName(): string |
|
83
|
|
|
{ |
|
84
|
|
|
return $this->name; |
|
85
|
3 |
|
} |
|
86
|
|
|
|
|
87
|
3 |
|
public function setName(string $name): WSDLBuilder |
|
88
|
|
|
{ |
|
89
|
|
|
IsValid::notEmpty($name, 'Name cannot be empty'); |
|
90
|
|
|
$this->name = $name; |
|
91
|
|
|
|
|
92
|
|
|
return $this; |
|
93
|
|
|
} |
|
94
|
|
|
|
|
95
|
8 |
|
public function getTargetNamespace(): string |
|
96
|
|
|
{ |
|
97
|
8 |
|
return $this->targetNamespace; |
|
98
|
7 |
|
} |
|
99
|
7 |
|
|
|
100
|
|
|
public function setTargetNamespace(string $targetNamespace): WSDLBuilder |
|
101
|
|
|
{ |
|
102
|
|
|
IsValid::notEmpty($targetNamespace, 'Target namespace cannot be empty'); |
|
103
|
|
|
$this->targetNamespace = $targetNamespace; |
|
104
|
|
|
|
|
105
|
2 |
|
return $this; |
|
106
|
|
|
} |
|
107
|
2 |
|
|
|
108
|
|
|
public function getNs(): string |
|
109
|
|
|
{ |
|
110
|
|
|
return $this->ns; |
|
111
|
|
|
} |
|
112
|
|
|
|
|
113
|
|
|
public function setNs(string $ns): WSDLBuilder |
|
114
|
|
|
{ |
|
115
|
8 |
|
IsValid::notEmpty($ns, 'NS cannot be empty'); |
|
116
|
|
|
$this->ns = $ns; |
|
117
|
8 |
|
|
|
118
|
7 |
|
return $this; |
|
119
|
7 |
|
} |
|
120
|
|
|
|
|
121
|
|
|
public function getLocation(): string |
|
122
|
|
|
{ |
|
123
|
|
|
return $this->location; |
|
124
|
|
|
} |
|
125
|
2 |
|
|
|
126
|
|
|
public function setLocation(string $location): WSDLBuilder |
|
127
|
2 |
|
{ |
|
128
|
|
|
IsValid::notEmpty($location, 'Location cannot be empty'); |
|
129
|
|
|
$this->location = $location; |
|
130
|
|
|
|
|
131
|
|
|
return $this; |
|
132
|
|
|
} |
|
133
|
|
|
|
|
134
|
|
|
public function getStyle(): string |
|
135
|
8 |
|
{ |
|
136
|
|
|
return $this->style; |
|
137
|
8 |
|
} |
|
138
|
7 |
|
|
|
139
|
7 |
|
public function setStyle(string $style): WSDLBuilder |
|
140
|
|
|
{ |
|
141
|
|
|
IsValid::style($style); |
|
142
|
|
|
$this->style = $style; |
|
143
|
|
|
|
|
144
|
|
|
return $this; |
|
145
|
2 |
|
} |
|
146
|
|
|
|
|
147
|
2 |
|
public function getUse(): string |
|
148
|
|
|
{ |
|
149
|
|
|
return $this->use; |
|
150
|
|
|
} |
|
151
|
|
|
|
|
152
|
|
|
public function setUse(string $use): WSDLBuilder |
|
153
|
|
|
{ |
|
154
|
|
|
IsValid::useStyle($use); |
|
155
|
8 |
|
$this->use = $use; |
|
156
|
|
|
|
|
157
|
8 |
|
return $this; |
|
158
|
7 |
|
} |
|
159
|
7 |
|
|
|
160
|
|
|
public function getParameterStyle(): string |
|
161
|
|
|
{ |
|
162
|
|
|
return $this->parameterStyle; |
|
163
|
|
|
} |
|
164
|
|
|
|
|
165
|
2 |
|
public function setParameterStyle(string $parameterStyle): WSDLBuilder |
|
166
|
|
|
{ |
|
167
|
2 |
|
IsValid::parameterStyle($parameterStyle, $this->style); |
|
168
|
|
|
$this->parameterStyle = $parameterStyle; |
|
169
|
|
|
|
|
170
|
|
|
return $this; |
|
171
|
|
|
} |
|
172
|
|
|
|
|
173
|
|
|
public function getSoapVersion(): string |
|
174
|
|
|
{ |
|
175
|
6 |
|
return $this->soapVersion; |
|
176
|
|
|
} |
|
177
|
6 |
|
|
|
178
|
5 |
|
public function setSoapVersion(string $soapVersion): WSDLBuilder |
|
179
|
5 |
|
{ |
|
180
|
|
|
IsValid::soapVersion($soapVersion); |
|
181
|
|
|
$this->soapVersion = $soapVersion; |
|
182
|
|
|
|
|
183
|
|
|
return $this; |
|
184
|
|
|
} |
|
185
|
2 |
|
|
|
186
|
|
|
/** |
|
187
|
2 |
|
* @return Method[] |
|
188
|
|
|
*/ |
|
189
|
|
|
public function getMethods(): array |
|
190
|
|
|
{ |
|
191
|
|
|
return $this->methods; |
|
192
|
|
|
} |
|
193
|
|
|
|
|
194
|
6 |
|
public function setMethod(Method $method): WSDLBuilder |
|
195
|
|
|
{ |
|
196
|
6 |
|
$this->methods[] = $method; |
|
197
|
5 |
|
|
|
198
|
5 |
|
return $this; |
|
199
|
|
|
} |
|
200
|
|
|
|
|
201
|
|
|
/** |
|
202
|
|
|
* @param Method[] $methods |
|
203
|
|
|
* @return $this |
|
204
|
1 |
|
*/ |
|
205
|
|
|
public function setMethods(array $methods): WSDLBuilder |
|
206
|
1 |
|
{ |
|
207
|
|
|
foreach ($methods as $method) { |
|
208
|
|
|
$this->setMethod($method); |
|
209
|
|
|
} |
|
210
|
|
|
|
|
211
|
|
|
return $this; |
|
212
|
|
|
|
|
213
|
|
|
} |
|
214
|
5 |
|
|
|
215
|
|
|
public function getPortName(): string |
|
216
|
5 |
|
{ |
|
217
|
4 |
|
return $this->portName; |
|
218
|
4 |
|
} |
|
219
|
|
|
|
|
220
|
|
|
public function setPortName(string $portName): WSDLBuilder |
|
221
|
|
|
{ |
|
222
|
|
|
$this->portName = $portName; |
|
223
|
|
|
|
|
224
|
2 |
|
return $this; |
|
225
|
|
|
} |
|
226
|
|
|
} |
|
227
|
|
|
|