summaryrefslogtreecommitdiff
path: root/src/Support/Parser.php
diff options
context:
space:
mode:
Diffstat (limited to 'src/Support/Parser.php')
-rw-r--r--src/Support/Parser.php27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/Support/Parser.php b/src/Support/Parser.php
new file mode 100644
index 0000000..d850de1
--- /dev/null
+++ b/src/Support/Parser.php
@@ -0,0 +1,27 @@
+<?php
+
+namespace App\Support;
+
+class Parser
+{
+ /**
+ * @return array<string, string>
+ */
+ public static function parseUser(string $user): array
+ {
+ $username = $user;
+ $server = "";
+
+ if (str_starts_with($user, "@")) {
+ $username = substr($user, 1);
+ $usernameParts = explode(":", $username);
+ $username = $usernameParts[0];
+ $server = $usernameParts[1];
+ }
+
+ return [
+ "username" => $username,
+ "server" => $server,
+ ];
+ }
+}