1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace SmsaSDK; |
4
|
|
|
|
5
|
|
|
/** |
6
|
|
|
* Smsa |
7
|
|
|
* Smsa Web Services (SECOM) Facade. |
8
|
|
|
*/ |
9
|
|
|
class Smsa |
10
|
|
|
{ |
11
|
|
|
use MethodsRedirector; |
12
|
|
|
/** |
13
|
|
|
* The base Smsa manager instance. |
14
|
|
|
* |
15
|
|
|
* @var \SmsaSDK\SmsaManager|null |
16
|
|
|
*/ |
17
|
|
|
private static $smsaManager = null; |
18
|
|
|
|
19
|
|
|
/** |
20
|
|
|
* setUp |
21
|
|
|
* Set up Smsa Configuration by the given config array |
22
|
|
|
* The array has 'key' and 'uri' as keys to it's values. |
23
|
|
|
* |
24
|
|
|
* @param array|null $config |
25
|
|
|
* |
26
|
|
|
* @return static |
27
|
|
|
*/ |
28
|
1 |
|
public static function setUp($config = []) |
29
|
|
|
{ |
30
|
1 |
|
static::handleStaticCalls('setUp', [$config]); |
31
|
|
|
|
32
|
1 |
|
return new static(); |
33
|
|
|
} |
34
|
|
|
|
35
|
|
|
/** |
36
|
|
|
* nullValues |
37
|
|
|
* Set the default value of the empty values that shall be sent to SECOM. |
38
|
|
|
* |
39
|
|
|
* @return static |
40
|
|
|
*/ |
41
|
1 |
|
public static function nullValues($value) |
42
|
|
|
{ |
43
|
1 |
|
static::handleStaticCalls('nullValues', [$value]); |
44
|
|
|
|
45
|
1 |
|
return new static(); |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
/** |
49
|
|
|
* uri |
50
|
|
|
* Set the WSDL uri. |
51
|
|
|
* |
52
|
|
|
* @return static |
53
|
|
|
*/ |
54
|
|
|
public static function uri($uri) |
55
|
|
|
{ |
56
|
|
|
static::handleStaticCalls('uri', [$uri]); |
57
|
|
|
|
58
|
|
|
return new static(); |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
/** |
62
|
|
|
* key |
63
|
|
|
* Set the SMSA Key. |
64
|
|
|
* |
65
|
|
|
* @return static |
66
|
|
|
*/ |
67
|
2 |
|
public static function key($passkey) |
68
|
|
|
{ |
69
|
2 |
|
static::handleStaticCalls('key', [$passkey]); |
70
|
|
|
|
71
|
2 |
|
return new static(); |
72
|
|
|
} |
73
|
|
|
|
74
|
|
|
/** |
75
|
|
|
* __callStatic |
76
|
|
|
* Calling static methods. |
77
|
|
|
* |
78
|
|
|
* @param string $method |
79
|
|
|
* @param array $arguments |
80
|
|
|
* |
81
|
|
|
* @return |
82
|
|
|
*/ |
83
|
7 |
|
public static function __callStatic($method, $arguments) |
84
|
|
|
{ |
85
|
7 |
|
return static::handleStaticCalls($method, $arguments); |
86
|
|
|
} |
87
|
|
|
|
88
|
|
|
/** |
89
|
|
|
* handleStaticCalls. |
90
|
|
|
* |
91
|
|
|
* @param string $method |
92
|
|
|
* @param array $arguments |
93
|
|
|
* |
94
|
|
|
* @return |
95
|
|
|
*/ |
96
|
8 |
|
public static function handleStaticCalls($method, $arguments) |
97
|
|
|
{ |
98
|
8 |
|
if (empty(static::$smsaManager)) { |
99
|
1 |
|
static::setManager(); |
100
|
1 |
|
} |
101
|
|
|
|
102
|
8 |
|
return static::$smsaManager->{$method}(...$arguments); |
|
|
|
|
103
|
|
|
} |
104
|
|
|
|
105
|
|
|
/** |
106
|
|
|
* setManager |
107
|
|
|
* Set the base Smsa manager. |
108
|
|
|
* |
109
|
|
|
* @param SmsaSDK\SmsaManager|null|mixed $smsaManager |
110
|
|
|
* |
111
|
|
|
* @return void |
112
|
|
|
*/ |
113
|
6 |
|
protected static function setManager($smsaManager = null) |
114
|
|
|
{ |
115
|
6 |
|
static::$smsaManager = $smsaManager ?: new SmsaManager(); |
|
|
|
|
116
|
6 |
|
} |
117
|
|
|
|
118
|
|
|
/** |
119
|
|
|
* refresh |
120
|
|
|
* Refresh the Smsa manager instance by providing alternative instance if possible. |
121
|
|
|
* |
122
|
|
|
* @param SmsaSDK\SmsaManager|null|mixed $altSmsaManagaer |
123
|
|
|
* |
124
|
|
|
* @return void |
125
|
|
|
*/ |
126
|
5 |
|
public static function refresh($altSmsaManagaer = null) |
127
|
|
|
{ |
128
|
5 |
|
static::setManager($altSmsaManagaer); |
129
|
5 |
|
} |
130
|
|
|
} |
131
|
|
|
|
Let’s assume you have a class which uses late-static binding:
The code above will run fine in your PHP runtime. However, if you now create a sub-class and call the
getSomeVariable()
on that sub-class, you will receive a runtime error:In the case above, it makes sense to update
SomeClass
to useself
instead: