Dokumentation für Util.php hinzugefügt

This commit is contained in:
Matthias Grief
2024-11-14 12:31:27 +01:00
parent c160ca4c1e
commit 64e7d12778

View File

@@ -2,12 +2,22 @@
class Util
{
static function removeIllegalCharacters($string): string
/**
* Entfernt alle Zeichen außer A-Z, a-z, 0-9 sowie - und _
* @param string $string Eingabe mit möglicherweise ungültigen Zeichen
* @return string Eingabestring mit allen ungültigen Zeichen entfernt
*/
static function removeIllegalCharacters(string $string): string
{
return preg_replace("/[^a-zA-Z0-9_-]/", "", $string);
}
static function parseJsonFromFile($filename): mixed
/**
* Öffnet eine Datei und gibt JSON-Inhalte als Array zurück
* @param string $filename Dateipfad
* @return mixed Array mit Key-Value Paaren
*/
static function parseJsonFromFile(string $filename): mixed
{
$file = fopen($filename, "r") or die("Unable to open file!");
$fileContent = fread($file, filesize($filename));