protected function resolveValue($name, &$source = null, $sanitize = true, $array = false)
    {
        $result = $array ? array() : null;

        if (empty($name)) {
            $result = $source;
        }
        elseif (isset($source[$name])) {
            $result = $source[$name];
        }

        if (!$sanitize) {
            return $result;
        }

        if (is_array($result)) {
            foreach ($result as $key => $value) {
                $result[$key] = $this->resolveValue('', $value, $sanitize);
            }
        }
        else {
            $filter = 0;
            $flags  = FILTER_FLAG_EMPTY_STRING_NULL | FILTER_NULL_ON_FAILURE;

            if ($sanitize) {
                $filter = $filter | FILTER_SANITIZE_STRING;
                $flags  = $flags | FILTER_FLAG_STRIP_LOW | FILTER_FLAG_STRIP_HIGH;
            }

            if ($array) {
                $flags = $flags | FILTER_FORCE_ARRAY;
            }

            $result = filter_var($result, $filter, array('flags' => $flags));
        }

        return $result;
    }
protected function resolveValue($name, &$source = null, $sanitize = true, $array = false)
    {
        $result = $array ? array() : null;

        if (empty($name)) {
            $result = $source;
        }
        elseif (isset($source[$name])) {
            $result = $source[$name];
        }

        if (!$sanitize) {
            return $result;
        }

        if (is_array($result)) {
            foreach ($result as $key => $value) {
                $result[$key] = $this->resolveValue('', $value, $sanitize);
            }
        }
        else {
            $filter = 0;
            $flags  = FILTER_FLAG_EMPTY_STRING_NULL | FILTER_NULL_ON_FAILURE;

            if ($sanitize) {
                $filter = $filter | FILTER_SANITIZE_STRING;
                $flags  = $flags | FILTER_FLAG_STRIP_LOW | FILTER_FLAG_STRIP_HIGH;
            }

            if ($array) {
                $flags = $flags | FILTER_FORCE_ARRAY;
            }

            $result = filter_var($result, $filter, array('flags' => $flags));
        }

        return $result;
    }
protected function resolveValue ( $ name , & $ source = null , $ sanitize = true , $ array = false ) { $ result = $ array ? array ( ) : null ; if ( empty ( $ name ) ) { $ result = $ source ; } elseif ( isset ( $ source [ $ name ] ) ) { $ result = $ source [ $ name ] ; } if ( ! $ sanitize ) { return $ result ; } if ( is_array ( $ result ) ) { foreach ( $ result as $ key => $ value ) { $ result [ $ key ] = $ this -> resolveValue ( '' , $ value , $ sanitize ) ; } } else { $ filter = 0 ; $ flags = FILTER_FLAG_EMPTY_STRING_NULL | FILTER_NULL_ON_FAILURE ; if ( $ sanitize ) { $ filter = $ filter | FILTER_SANITIZE_STRING ; $ flags = $ flags | FILTER_FLAG_STRIP_LOW | FILTER_FLAG_STRIP_HIGH ; } if ( $ array ) { $ flags = $ flags | FILTER_FORCE_ARRAY ; } $ result = filter_var ( $ result , $ filter , array ( 'flags' => $ flags ) ) ; } return $ result ; }
Resolve a value from the given collection.

@param string $name
@param array  $source
@param bool   $sanitize
@param bool   $array

@return mixed
Resolve a value from the given collection .