From ac42824b920b4073ff7c1823779f10a10832edc9 Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Wed, 27 May 2015 00:22:54 -0400 Subject: [PATCH] Add Request::Filter and ::FilterArray. --- http/request.php | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/http/request.php b/http/request.php index ff48b00..031518b 100644 --- a/http/request.php +++ b/http/request.php @@ -40,4 +40,24 @@ class Request extends \hoplite\base\StrictObject { $this->url = $url; } + + /*! + Wrapper around filter_input() that stores the result in the ::$data field. + */ + public function Filter($type, $name, $filter=FILTER_SANITIZE_STRING, $options=NULL) + { + $rv = filter_input($type, $name, $filter, $options); + $this->data[$name] = $rv; + return $rv; + } + + /*! + Wrapper around filter_input() that merges the result in the ::$data field. + */ + public function FilterArray($type, $definition, $add_empty=TRUE) + { + $rv = filter_input_array($type, $definition, $add_empty); + $this->data = array_merge($this->data, $rv); + return $rv; + } } -- 2.22.5