Airship\Engine\Security\Filter\InputFilterContainer::filterValue PHP Method

filterValue() public method

Use firstlevel.second_level.thirdLevel to find indices in an array
public filterValue ( string $key, mixed $multiDimensional ) : mixed
$key string
$multiDimensional mixed
return mixed
    public function filterValue(string $key, $multiDimensional)
    {
        $pieces = \Airship\chunk($key, '.');
        $filtered =& $multiDimensional;
        /**
         * @security This shouldn't be escapable. We know eval is evil, but
         *           there's not a more elegant way to process this in PHP.
         */
        if (\is_array($multiDimensional)) {
            $var = '$multiDimensional';
            foreach ($pieces as $piece) {
                $append = '[' . self::sanitize($piece) . ']';
                // Alphabetize the parent array
                eval('if (!isset(' . $var . $append . ')) {' . "\n" . '    ' . $var . $append . ' = null;' . "\n" . '}' . "\n" . '\\ksort(' . $var . ');' . "\n");
                $var .= $append;
            }
            eval('$filtered =& ' . $var . ';');
        }
        // If we have filters, let's apply them:
        if (isset($this->filterMap[$key])) {
            foreach ($this->filterMap[$key] as $filter) {
                if ($filter instanceof FilterInterface) {
                    $filtered = $filter->process($filtered);
                }
            }
        }
        return $multiDimensional;
    }