summaryrefslogtreecommitdiff
path: root/src/Support
diff options
context:
space:
mode:
Diffstat (limited to 'src/Support')
-rw-r--r--src/Support/ArrayTransformable.php11
-rw-r--r--src/Support/Id.php21
-rw-r--r--src/Support/Logger.php1
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(