From 324845a855d9506a14a2d823c71274eafe966049 Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Wed, 15 Jun 2011 12:42:52 -0700 Subject: [PATCH] Added Input::filled, Input::had, and Input::was_filled. --- system/input.php | 42 +++++++++++++++++++++++++++++++++++++++--- 1 file changed, 39 insertions(+), 3 deletions(-) diff --git a/system/input.php b/system/input.php index 095ca2e5..91b7862a 100644 --- a/system/input.php +++ b/system/input.php @@ -18,7 +18,25 @@ class Input { { foreach (func_get_args() as $key) { - if (is_null($value = static::get($key)) or trim((string) $value) == '') + if (is_null(static::get($key))) + { + return false; + } + } + + return true; + } + + /** + * Determine if the input data contains an item or set of items that are not empty. + * + * @return bool + */ + public static function filled() + { + foreach (func_get_args() as $key) + { + if ( ! static::has($key) or trim((string) static::get($key)) == '') { return false; } @@ -49,11 +67,29 @@ class Input { * * @return bool */ - public static function has_old() + public static function had() { foreach (func_get_args() as $key) { - if (is_null($value = static::old($key)) or trim((string) $value) == '') + if (is_null(static::old($key))) + { + return false; + } + } + + return true; + } + + /** + * Determine if the old input data contains an item or set of items that are not empty. + * + * @return bool + */ + public static function was_filled() + { + foreach (func_get_args() as $key) + { + if ( ! static::had($key) or trim((string) static::old($key)) == '') { return false; }