Total Complexity | 7 |
Total Lines | 48 |
Duplicated Lines | 0 % |
Changes | 4 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
11 | final class Helper |
||
12 | { |
||
13 | protected const ALGORITHM_HS256 = 'HS256'; |
||
14 | |||
15 | public static function generate(string $clientId, string $clientKey, string $serverKey): string |
||
16 | { |
||
17 | return JWT::encode( |
||
18 | // Do not change array key order here, it is important (unit test fails). |
||
19 | // phpcs:ignore SlevomatCodingStandard.Arrays.AlphabeticallySortedByKeys.IncorrectKeyOrder |
||
20 | [ |
||
21 | 'sub' => $clientId, |
||
22 | 'clientKey' => $clientKey, |
||
23 | ], // payload PHP object or array |
||
24 | $serverKey, // key The secret key. |
||
25 | self::ALGORITHM_HS256, // alg The signing algorithm. |
||
26 | ); |
||
27 | } |
||
28 | |||
29 | public static function decode(string $jwt, string $serverKey): Payload |
||
59 | } |
||
60 | } |
||
61 |