You are here

function twig_in_filter in Translation template extractor 6.3

Same name and namespace in other branches
  1. 7.3 vendor/Twig/Extension/Core.php \twig_in_filter()

File

vendor/Twig/Extension/Core.php, line 930

Code

function twig_in_filter($value, $compare) {
  if (is_array($compare)) {
    return in_array($value, $compare, is_object($value));
  }
  elseif (is_string($compare)) {
    if (!strlen($value)) {
      return empty($compare);
    }
    return false !== strpos($compare, (string) $value);
  }
  elseif ($compare instanceof Traversable) {
    return in_array($value, iterator_to_array($compare, false), is_object($value));
  }
  return false;
}