diff options
| author | Daniel Weipert <git@mail.dweipert.de> | 2026-03-05 14:57:28 +0100 |
|---|---|---|
| committer | Daniel Weipert <git@mail.dweipert.de> | 2026-03-05 14:57:28 +0100 |
| commit | bd11271621bd3759cfd194ed0119c0dc28155fd0 (patch) | |
| tree | 319b4790d4e2b05513abf023732ed6fb0717f603 /src/Support | |
| parent | 2386148b8f048ba40d9f26cc97898bdcdc778ea2 (diff) | |
Diffstat (limited to 'src/Support')
| -rw-r--r-- | src/Support/ArrayTransformable.php | 11 | ||||
| -rw-r--r-- | src/Support/Id.php | 21 | ||||
| -rw-r--r-- | src/Support/Logger.php | 1 |
3 files changed, 22 insertions, 11 deletions
diff --git a/src/Support/ArrayTransformable.php b/src/Support/ArrayTransformable.php deleted file mode 100644 index f1adf81..0000000 --- a/src/Support/ArrayTransformable.php +++ /dev/null @@ -1,11 +0,0 @@ -<?php - -namespace App\Support; - -interface ArrayTransformable -{ - /** - * @return array - */ - public function toArray(): array; -} diff --git a/src/Support/Id.php b/src/Support/Id.php new file mode 100644 index 0000000..dc23631 --- /dev/null +++ b/src/Support/Id.php @@ -0,0 +1,21 @@ +<?php + +namespace App\Support; + +class Id +{ + public static function generate(string $prefix = "", string $suffix = "", string $salt = ""): string + { + return $prefix . md5(time() . random_bytes(512)) . $suffix; + } + + public static function generateRoomId(): string + { + return self::generate(prefix: "!", suffix: ":" . $_ENV["DOMAIN"]); + } + + public static function generateEventId(): string + { + return self::generate(prefix: "$", suffix: ":" . $_ENV["DOMAIN"]); + } +} diff --git a/src/Support/Logger.php b/src/Support/Logger.php index c806157..b01af11 100644 --- a/src/Support/Logger.php +++ b/src/Support/Logger.php @@ -9,6 +9,7 @@ class Logger implements LoggerInterface { public static function logRequestToFile(Request $request): void { + @mkdir(dirname(dirname(__DIR__)) . "/.cache/log", recursive: true); $basePath = dirname(dirname(__DIR__)) . "/.cache/log/" . str_replace("/", "_", $request->getPathInfo()); file_put_contents( |
