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
|
|
|
use WSDL\Builder\Method; |
25
|
|
|
use WSDL\Builder\Parameter; |
26
|
|
|
use WSDL\Lexer\Tokenizer; |
27
|
|
|
|
28
|
|
|
/** |
29
|
|
|
* MethodsProvider |
30
|
|
|
* |
31
|
|
|
* @author Piotr Olaszewski <[email protected]> |
32
|
|
|
*/ |
33
|
|
|
class MethodsProvider |
|
|
|
|
34
|
|
|
{ |
35
|
|
|
/** |
36
|
|
|
* @return Method[] |
37
|
|
|
* @throws Exception |
38
|
|
|
*/ |
39
|
|
|
public static function get() |
40
|
|
|
{ |
41
|
|
|
$tokenizer = new Tokenizer(); |
42
|
|
|
|
43
|
|
|
$parameters1 = [Parameter::fromTokens($tokenizer->lex('string $userName'))]; |
44
|
|
|
$return1 = Parameter::fromTokens($tokenizer->lex('string $uppercasedUserName')); |
45
|
|
|
|
46
|
|
|
$parameters2 = [ |
47
|
|
|
Parameter::fromTokens($tokenizer->lex('int[] $numbers')), |
48
|
|
|
Parameter::fromTokens($tokenizer->lex('string $prefix')) |
49
|
|
|
]; |
50
|
|
|
$return2 = Parameter::fromTokens($tokenizer->lex('string[] $numbersWithPrefix')); |
51
|
|
|
|
52
|
|
|
$parameters3 = [Parameter::fromTokens($tokenizer->lex('object $user { string $name int $age }'))]; |
53
|
|
|
$return3 = Parameter::fromTokens($tokenizer->lex('object $userContext { int $id object $userInfo { string $name int $age } }')); |
54
|
|
|
|
55
|
|
|
$parameters4 = [Parameter::fromTokens($tokenizer->lex('object[] $companies { string $name int $postcode }'))]; |
56
|
|
|
$return4 = Parameter::fromTokens($tokenizer->lex('string[] $companiesNames')); |
57
|
|
|
|
58
|
|
|
$parameters5 = [Parameter::fromTokens($tokenizer->lex('string[] $errors'))]; |
59
|
|
|
$return5 = Parameter::fromTokens($tokenizer->lex('object $result { boolean $result string[] $errors }')); |
60
|
|
|
|
61
|
|
|
$parameters6 = [ |
62
|
|
|
Parameter::fromTokens($tokenizer->lex('object $serviceAuth { string $token int $id }'), true), |
63
|
|
|
Parameter::fromTokens($tokenizer->lex('string $name')), |
64
|
|
|
Parameter::fromTokens($tokenizer->lex('string $surname')) |
65
|
|
|
]; |
66
|
|
|
$return6 = Parameter::fromTokens($tokenizer->lex('string $nameWithSurname')); |
67
|
|
|
|
68
|
|
|
$parameters7 = [Parameter::fromTokens($tokenizer->lex('string $userToken'))]; |
69
|
|
|
|
70
|
|
|
$return8 = Parameter::fromTokens($tokenizer->lex('string $responseForMethodWithoutParameters')); |
71
|
|
|
|
72
|
|
|
return [ |
73
|
|
|
new Method('uppercaseUserName', $parameters1, $return1), |
74
|
|
|
new Method('appendPrefixToNumbers', $parameters2, $return2), |
75
|
|
|
new Method('getUserContext', $parameters3, $return3), |
76
|
|
|
new Method('extractCompaniesNames', $parameters4, $return4), |
77
|
|
|
new Method('wrapErrors', $parameters5, $return5), |
78
|
|
|
new Method('authorizedMethod', $parameters6, $return6), |
79
|
|
|
new Method('methodWithoutReturn', $parameters7, null), |
80
|
|
|
new Method('methodWithoutParameters', [], $return8) |
81
|
|
|
]; |
82
|
|
|
} |
83
|
|
|
} |
84
|
|
|
|
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.