/** * @param array $data * @param string $encoding * @return array */ public static function filterData(array $data, string $encoding = "ascii") : array { foreach ($data as $key => $value) { if (is_string($value)) { if ($encoding === "ascii") { $data[$key] = Strings::filter($value, "adsq", true); } else { $data[$key] = filter_var($value, FILTER_SANITIZE_STRING, FILTER_FLAG_STRIP_LOW); } } elseif (is_array($value)) { $data[$key] = self::filterData($value, $encoding); } } return $data; }
/** * @param string $path * @param string $extra * @return string */ private function filterPath(string $path, string $extra = "") : string { // Filter path //$path = explode("?", strtolower($path))[0]; $path = trim(Strings::filter($path, "ad", false, "/-_" . $extra), "\\/"); return $path ? $path : "/"; }