This repository has been archived by the owner on May 9, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
/
SoapClient.php
100 lines (91 loc) · 2.31 KB
/
SoapClient.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
<?php
namespace SmsaSDK;
/**
* SoapClient
* Insert description here.
*/
class SoapClient extends \SoapClient
{
public static $testing = false;
public static $lastException = null;
public static $client = null;
public static $lastCall = null;
/**
* __soapCall
* Insert description here.
*
* @param $function_name
* @param $arguments
* @param $options
* @param $input_headers
* @param $output_headers
*
* @return
*/
public function __soapCall($function_name, $arguments, $options = null, $input_headers = null, &$output_headers = null)
{
static::$lastCall = compact('function_name', 'arguments', 'options', 'input_headers', 'output_headers');
// if the alternative client was set, for testing or customization for example
if (static::$client) {
return static::$client->$function_name($arguments);
}
return $this->soapCall($function_name, $arguments, $options, $input_headers, $output_headers);
}
/**
* soapCall
* Insert description here.
*
* @param $function_name
* @param $arguments
* @param $options
* @param $input_headers
* @param $output_headers
*
* @return
*/
private function soapCall($function_name, $arguments, $options = null, $input_headers = null, &$output_headers = null)
{
try {
return parent::__soapCall($function_name, $arguments, $options, $input_headers, $output_headers);
} catch (\Exception $e) {
static::$lastException = $e;
if (!static::$testing) {
throw $e;
}
}
}
/**
* setTestingClient
* Insert description here.
*
* @param $client
*
* @return
*/
public static function setTestingClient($client = null)
{
static::$testing = true;
static::$client = $client;
}
/**
* getTestingClient
* Insert description here.
*
* @return
*/
public static function getTestingClient()
{
return static::$client;
}
/**
* turnOffTestingClient
* Insert description here.
*
* @return
*/
public static function turnOffTestingClient()
{
static::$testing = false;
static::$client = null;
}
}