mantis-matrix-integration – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | office | 1 | <?php |
2 | |||
3 | namespace MatrixPhp; |
||
4 | |||
5 | use MatrixPhp\Exceptions\ValidationException; |
||
6 | |||
7 | class Util { |
||
8 | |||
9 | /** |
||
10 | * Check if provided roomId is valid |
||
11 | * |
||
12 | * @param string $roomId |
||
13 | * @throws ValidationException |
||
14 | */ |
||
15 | public static function checkRoomId(string $roomId) { |
||
16 | if (strpos($roomId, '!') !== 0) { |
||
17 | throw new ValidationException("RoomIDs start with !"); |
||
18 | } |
||
19 | |||
20 | if (strpos($roomId, ':') === false) { |
||
21 | throw new ValidationException("RoomIDs must have a domain component, seperated by a :"); |
||
22 | } |
||
23 | } |
||
24 | |||
25 | /** |
||
26 | * Check if provided userId is valid |
||
27 | * |
||
28 | * @param string $userId |
||
29 | * @throws ValidationException |
||
30 | */ |
||
31 | public static function checkUserId(string $userId) { |
||
32 | if (strpos($userId, '@') !== 0) { |
||
33 | throw new ValidationException("UserIDs start with @"); |
||
34 | } |
||
35 | |||
36 | if (strpos($userId, ':') === false) { |
||
37 | throw new ValidationException("UserIDs must have a domain component, seperated by a :"); |
||
38 | } |
||
39 | } |
||
40 | |||
41 | public static function checkMxcUrl(string $mxcUrl) { |
||
42 | if (substr($mxcUrl, 0, 6) != 'mxc://') { |
||
43 | throw new ValidationException('MXC URL did not begin with \'mxc://\''); |
||
44 | } |
||
45 | } |
||
46 | } |