/** * Collects the filter value from request variables, session variables, or cookie variables, in that order. * Insures that the value is converted to a TRUE, FALSE or NULL value. * @param bool $read_cookies Flag indicating that the cookie collection should included in the search for a * filter value. */ public function collectValue($read_cookies = true) { parent::collectValue($read_cookies); if ($this->value) { $this->value = Validation::parseBoolean($this->value); } }
/** * Returns TRUE/FALSE depending on the value of the requested inptu variable. * @param string $key Input variable name in either GET or POST data. * @param integer $index (Optional) index of the element to test, if the variable is an array. * @param array $src (Optional) array to use in place of GET or POST data. * @return boolean TRUE/FALSE depending on the value of the input variable. */ public static function parseBooleanInput($key, $index = null, $src = null) { $value = null; if ($src === null) { $src = array_merge($_GET, $_POST); } if (!isset($src[$key])) { return null; } if ($index !== null) { $arr = filter_var($src[$key], FILTER_SANITIZE_STRING, FILTER_REQUIRE_ARRAY); if (is_array($arr) && count($arr) >= $index - 1) { $value = $arr[$index]; } } else { $value = trim(filter_var($src[$key], FILTER_SANITIZE_STRING)); } return Validation::parseBoolean($value); }