Conditions | 2 |
Paths | 2 |
Total Lines | 14 |
Code Lines | 8 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php declare(strict_types = 1); |
||
23 | public static function generate(RequestInterface $request, string $issuer, string $secret, ?string $user): string |
||
24 | { |
||
25 | $data = [ |
||
26 | 'iss' => $issuer, |
||
27 | 'iat' => \time(), |
||
28 | 'exp' => \strtotime('+1 day'), |
||
29 | 'qsh' => QSHGenerator::generate((string) $request->getUri(), $request->getMethod()), |
||
30 | ]; |
||
31 | |||
32 | if ($user !== null) { |
||
33 | $data['sub'] = $user; |
||
34 | } |
||
35 | |||
36 | return JWT::encode($data, $secret); |
||
37 | } |
||
39 |