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 Ouzo\Utilities\Arrays; |
25
|
|
|
use Ouzo\Utilities\Functions; |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* ExampleService |
29
|
|
|
* |
30
|
|
|
* @author Piotr Olaszewski <[email protected]> |
31
|
|
|
*/ |
32
|
|
|
class ExampleService |
|
|
|
|
33
|
|
|
{ |
34
|
|
|
private $clientId = null; |
35
|
|
|
|
36
|
|
|
public function uppercaseUserName($userName) |
37
|
|
|
{ |
38
|
|
|
return strtoupper($userName); |
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
public function appendPrefixToNumbers($numbers, $prefix) |
42
|
|
|
{ |
43
|
|
|
return Arrays::map($numbers, Functions::prepend($prefix)); |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
public function getUserContext($user) |
47
|
|
|
{ |
48
|
|
|
$userContext = new stdClass(); |
49
|
|
|
$userContext->id = time(); |
50
|
|
|
$userContext->userInfo = new stdClass(); |
51
|
|
|
$userContext->userInfo->name = $user->name; |
52
|
|
|
$userContext->userInfo->age = $user->age; |
53
|
|
|
return $userContext; |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
public function extractCompaniesNames($companies) |
57
|
|
|
{ |
58
|
|
|
return Arrays::map($companies, Functions::extractField('name')); |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
public function wrapErrors($errors) |
62
|
|
|
{ |
63
|
|
|
$result = new stdClass(); |
64
|
|
|
$result->result = false; |
65
|
|
|
$result->errors = $errors; |
66
|
|
|
return $result; |
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
public function serviceAuth($object) |
70
|
|
|
{ |
71
|
|
|
if ($object->token != 'test_token') { |
72
|
|
|
throw new SoapFault('WT', 'Wrong token'); |
73
|
|
|
} else { |
74
|
|
|
$this->clientId = $object->id; |
75
|
|
|
} |
76
|
|
|
} |
77
|
|
|
|
78
|
|
|
public function authorizedMethod($name, $surname) |
79
|
|
|
{ |
80
|
|
|
return 'clientId [' . $this->clientId . '] name [' . $name . '] surname [' . $surname . ']'; |
81
|
|
|
} |
82
|
|
|
|
83
|
|
|
public function methodWithoutReturn($userToken) |
84
|
|
|
{ |
85
|
|
|
file_put_contents('/tmp/wsdl-creator-example-log', $userToken . PHP_EOL, FILE_APPEND); |
86
|
|
|
} |
87
|
|
|
|
88
|
|
|
public function methodWithoutParameters() |
89
|
|
|
{ |
90
|
|
|
return 'method without parameters'; |
91
|
|
|
} |
92
|
|
|
} |
93
|
|
|
|
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.