public function ParameterBag::filter

Filter key.

Parameters

string $key Key.:

mixed $default Default = null.:

boolean $deep Default = false.:

integer $filter FILTER_* constant.:

mixed $options Filter options.:

Return value

mixed

See also

http://php.net/manual/en/function.filter-var.php

1 call to ParameterBag::filter()
ParameterBag::getDigits in drupal/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/ParameterBag.php
Returns the digits of the parameter value.

File

drupal/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/ParameterBag.php, line 269

Class

ParameterBag
ParameterBag is a container for key/value pairs.

Namespace

Symfony\Component\HttpFoundation

Code

public function filter($key, $default = null, $deep = false, $filter = FILTER_DEFAULT, $options = array()) {
  $value = $this
    ->get($key, $default, $deep);

  // Always turn $options into an array - this allows filter_var option shortcuts.
  if (!is_array($options) && $options) {
    $options = array(
      'flags' => $options,
    );
  }

  // Add a convenience check for arrays.
  if (is_array($value) && !isset($options['flags'])) {
    $options['flags'] = FILTER_REQUIRE_ARRAY;
  }
  return filter_var($value, $filter, $options);
}