2
2
3
3
namespace Rapi ;
4
4
5
+ use phpList \Entity \SubscriberEntity ;
6
+ use Rapi \Handler \ListHandler ;
7
+ use Rapi \Handler \LoginHandler ;
8
+ use Rapi \Handler \SubscriberHandler ;
9
+
5
10
/**
6
11
* Class to handle API call functionality and execution
7
12
* @note This class is ignorant of call output and forwards it transparently --
@@ -11,24 +16,30 @@ class Call {
11
16
12
17
/**
13
18
* Constructor requires all classes that may handle calls as arguments
19
+ *
14
20
* @note To add support for an API call, add it's parent class to arguments
15
- * @param Lists $lists
16
- * @param SubscriberHandler $subscriberHandler
21
+ * @param Handler\ListHandler $listHandler
22
+ * @param Handler\SubscriberHandler|SubscriberHandler $subscriberHandler
23
+ * @param Handler\LoginHandler $loginHandler
24
+ * @internal param Lists $lists
17
25
*/
18
26
public function __construct (
19
- \ Rapi \ Handler \ ListHandler $ listHandler
20
- , \ Rapi \ Handler \ SubscriberHandler $ subscriberHandler
21
- , \ Rapi \ Handler \ LoginHandler $ loginHandler
27
+ ListHandler $ listHandler,
28
+ SubscriberHandler $ subscriberHandler,
29
+ LoginHandler $ loginHandler
22
30
)
23
31
{
24
32
$ this ->listHandler = $ listHandler ;
25
33
$ this ->subscriberHandler = $ subscriberHandler ;
26
34
$ this ->loginHandler = $ loginHandler ;
27
35
}
36
+
28
37
/**
29
38
* Validate a requested call by checking characters and syntax
39
+ *
30
40
* @param string $className Name of class to validate
31
41
* @param string $method Name of method to validate
42
+ *
32
43
* @return bool $result
33
44
*/
34
45
public function validateCall ( $ className , $ method )
@@ -55,7 +66,10 @@ public function validateCall( $className, $method )
55
66
56
67
/**
57
68
* Get API call configuraiton whitelist
69
+ *
58
70
* @param string $whitelistPath Path to whitelist configuration file
71
+ *
72
+ * @return mixed
59
73
*/
60
74
public function getWhitelistConfig ( $ whitelistPath = NULL )
61
75
{
@@ -83,7 +97,11 @@ public function getWhitelistConfig( $whitelistPath = NULL )
83
97
84
98
/**
85
99
* Check if the supplied class name is permitted by the whitelist
100
+ *
86
101
* @param string $className Class name to check
102
+ * @param string $method
103
+ *
104
+ * @return bool
87
105
*/
88
106
public function isCallWhitelisted ( $ className , $ method )
89
107
{
@@ -107,10 +125,12 @@ public function isCallWhitelisted( $className, $method )
107
125
108
126
/**
109
127
* Validate an API call and execute the requested method on handler object
128
+ *
110
129
* @param string $className to execute method on
111
130
* @param string $method name of method to execute
112
131
* @param array $argumentsArray arguments to pass to method
113
- * @return \phpList\Entity\SubscriberEntity Data object
132
+ *
133
+ * @return SubscriberEntity Data object
114
134
*/
115
135
public function doCall ( $ className , $ method , array $ argumentsArray )
116
136
{
@@ -143,7 +163,10 @@ public function doCall( $className, $method, array $argumentsArray )
143
163
144
164
/**
145
165
* Format raw user-privded API call parameters for passing to handler object
166
+ *
146
167
* @param array $argumentsArray user-supplied API call parameters
168
+ *
169
+ * @return array
147
170
*/
148
171
public function formatParams ( array $ argumentsArray ) {
149
172
@@ -159,7 +182,10 @@ public function formatParams( array $argumentsArray ) {
159
182
160
183
/**
161
184
* Convert any var type to an array suitable for passing to a response
185
+ *
162
186
* @param mixed $callResult Returned value of an executed API call
187
+ *
188
+ * @return array|mixed
163
189
*/
164
190
public function callResultToArray ( $ callResult )
165
191
{
@@ -191,10 +217,12 @@ public function callResultToArray( $callResult )
191
217
* This function converts an object into an associative array by iterating
192
218
* over its public properties. Because this function uses the foreach
193
219
* construct, Iterators are respected. It also works on arrays of objects.
220
+ *
194
221
* @param object $object The object to be converted
222
+ *
195
223
* @return array $result Converted object
196
224
*/
197
- function objectToArray ( $ object )
225
+ public function objectToArray ( $ object )
198
226
{
199
227
$ result = array ();
200
228
$ references = array ();
0 commit comments