summaryrefslogtreecommitdiff
path: root/src/Support/Parser.php
blob: d850de1462521ef441545810905b2fe97d7d16d2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
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,
    ];
  }
}