1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace SmsaSDK; |
4
|
|
|
|
5
|
|
|
/** |
6
|
|
|
* SoapClient |
7
|
|
|
* Insert description here. |
8
|
|
|
*/ |
9
|
|
|
class SoapClient extends \SoapClient |
10
|
|
|
{ |
11
|
|
|
public static $testing = false; |
12
|
|
|
public static $lastException = null; |
13
|
|
|
public static $client = null; |
14
|
|
|
public static $lastCall = null; |
15
|
|
|
|
16
|
|
|
/** |
17
|
|
|
* __soapCall |
18
|
|
|
* Insert description here. |
19
|
|
|
* |
20
|
|
|
* @param $function_name |
21
|
|
|
* @param $arguments |
22
|
|
|
* @param $options |
23
|
|
|
* @param $input_headers |
24
|
|
|
* @param $output_headers |
25
|
|
|
* |
26
|
|
|
* @return |
27
|
|
|
*/ |
28
|
3 |
|
public function __soapCall($function_name, $arguments, $options = null, $input_headers = null, &$output_headers = null) |
29
|
|
|
{ |
30
|
3 |
|
static::$lastCall = compact('function_name', 'arguments', 'options', 'input_headers', 'output_headers'); |
31
|
|
|
|
32
|
|
|
// if the alternative client was set, for testing or customization for example |
33
|
3 |
|
if (static::$client) { |
34
|
3 |
|
return static::$client->$function_name($arguments); |
35
|
|
|
} |
36
|
|
|
|
37
|
|
|
return $this->soapCall($function_name, $arguments, $options, $input_headers, $output_headers); |
38
|
|
|
} |
39
|
|
|
|
40
|
|
|
/** |
41
|
|
|
* soapCall |
42
|
|
|
* Insert description here. |
43
|
|
|
* |
44
|
|
|
* @param $function_name |
45
|
|
|
* @param $arguments |
46
|
|
|
* @param $options |
47
|
|
|
* @param $input_headers |
48
|
|
|
* @param $output_headers |
49
|
|
|
* |
50
|
|
|
* @return |
51
|
|
|
*/ |
52
|
|
|
private function soapCall($function_name, $arguments, $options = null, $input_headers = null, &$output_headers = null) |
53
|
|
|
{ |
54
|
|
|
try { |
55
|
|
|
return parent::__soapCall($function_name, $arguments, $options, $input_headers, $output_headers); |
|
|
|
|
56
|
|
|
} catch (\Exception $e) { |
57
|
|
|
static::$lastException = $e; |
58
|
|
|
if (!static::$testing) { |
59
|
|
|
throw $e; |
60
|
|
|
} |
61
|
|
|
} |
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
/** |
65
|
|
|
* setTestingClient |
66
|
|
|
* Insert description here. |
67
|
|
|
* |
68
|
|
|
* @param $client |
69
|
|
|
* |
70
|
|
|
* @return |
71
|
|
|
*/ |
72
|
4 |
|
public static function setTestingClient($client = null) |
73
|
|
|
{ |
74
|
4 |
|
static::$testing = true; |
75
|
4 |
|
static::$client = $client; |
76
|
4 |
|
} |
77
|
|
|
|
78
|
|
|
/** |
79
|
|
|
* getTestingClient |
80
|
|
|
* Insert description here. |
81
|
|
|
* |
82
|
|
|
* @return |
83
|
|
|
*/ |
84
|
3 |
|
public static function getTestingClient() |
85
|
|
|
{ |
86
|
3 |
|
return static::$client; |
87
|
|
|
} |
88
|
|
|
|
89
|
|
|
/** |
90
|
|
|
* turnOffTestingClient |
91
|
|
|
* Insert description here. |
92
|
|
|
* |
93
|
|
|
* @return |
94
|
|
|
*/ |
95
|
1 |
|
public static function turnOffTestingClient() |
96
|
|
|
{ |
97
|
1 |
|
static::$testing = false; |
98
|
1 |
|
static::$client = null; |
99
|
1 |
|
} |
100
|
|
|
} |
101
|
|
|
|
This check looks for a call to a parent method whose name is different than the method from which it is called.
Consider the following code:
The
getFirstName()
method in theSon
calls the wrong method in the parent class.