public function filter($data = null, $filter = false)
    {
        if (is_null($data)) {
            return null;
        }

        if (is_array($data)) {
            return array_map(function ($value) use ($filter) {
                return $this->filter($value, $filter);
            }, $data);
        }

        return ($filter == true ? $this->xssClean($data) : trim($data));
    }