@@ -284,21 +284,37 @@ public static function getMethod() : string {
284284 * @since 1.0.1
285285 */
286286 public static function getParam (string $ paramName ) {
287- $ requMethod = self :: getMethod ();
287+
288288 $ trimmed = trim ($ paramName );
289- $ val = null ;
289+ $ params = self :: getParams () ;
290290
291- if ($ requMethod == 'POST ' || $ requMethod == 'PUT ' ) {
292- $ val = self ::filter (INPUT_POST , $ trimmed );
293- } else if ($ requMethod == 'DELETE ' || $ requMethod == 'GET ' ) {
294- $ val = self ::filter (INPUT_GET , $ trimmed );
291+ if (isset ($ params [$ trimmed ])) {
292+ return $ params [$ trimmed ];
295293 }
296294
297- if ($ val === false ) {
298- return null ;
295+ return null ;
296+ }
297+ /**
298+ * Returns an array that contains all POST or GET parameters.
299+ *
300+ * @return array An array that contains all POST or GET parameters. The
301+ * indices of the array are parameters names and the value of each index
302+ * is the value of the parameter.
303+ */
304+ public static function getParams () : array {
305+ $ requMethod = self ::getMethod ();
306+ $ retVal = [];
307+
308+ if ($ requMethod == 'POST ' || $ requMethod == 'PUT ' ) {
309+ foreach (array_keys ($ _POST ) as $ name ) {
310+ $ retVal [$ name ] = self ::filter (INPUT_POST , $ name );
311+ }
312+ } else if ($ requMethod == 'DELETE ' || $ requMethod == 'GET ' ) {
313+ foreach (array_keys ($ _GET ) as $ name ) {
314+ $ retVal [$ name ] = self ::filter (INPUT_GET , $ name );
315+ }
299316 }
300-
301- return $ val ;
317+ return $ retVal ;
302318 }
303319 /**
304320 * Returns the URI of the requested resource.
0 commit comments