/** * Validates $_SESSION[$key] value * * @param string $key - key parameter of $_SESSION * @param mixed $default - return value if key is not found * @return mixed - string on success ($_SESSION[$key] value) or $default on failure */ public static function session($key, $default = null) { return Filter::key($key, $_SESSION, $default); }
protected function getAttribute($name) { return Filter::key($name, $this->attributes); }
public function getControl($name) { return Filter::key($name, $this->controls); }
protected function regex_key_prc($match) { return "(?P<{$match[1]}>" . Filter::key($match[1], $this->segments, static::REGEX_SEGMENT) . ')'; }
/** * Get accept status. * * @return bool */ public function accept() { if (is_array(parent::current())) { return false; } $this->_key = parent::key(); $this->_current = parent::current(); $matches = []; $useKey = $this->_flags & self::USE_KEY; $subject = $useKey ? $this->_key : $this->_current; $out = false; switch ($this->_mode) { case self::MATCH: $out = 0 !== preg_match($this->_regex, $subject, $matches, $this->_pregFlags); break; case self::GET_MATCH: $this->_current = []; $out = 0 !== preg_match($this->_regex, $subject, $this->_current, $this->_pregFlags); break; case self::ALL_MATCHES: $this->_current = []; $out = 0 < preg_match_all($this->_regex, $subject, $this->_current, $this->_pregFlags); break; case self::SPLIT: $this->_current = preg_split($this->_regex, $subject, null, $this->_pregFlags); $out = is_array($this->_current) && 1 < count($this->_current); break; case self::REPLACE: $numberOfReplacement = 0; $result = preg_replace($this->_regex, $this->replacement, $subject, -1, $numberOfReplacement); if (null === $result || 0 === $numberOfReplacement) { $out = false; break; } if (0 !== $useKey) { $this->_key = $result; $out = true; break; } $this->_current = $result; $out = true; break; default: $out = false; break; } if (0 !== ($this->_flags & self::INVERT_MATCH)) { return false === $out; } return $out; }