| Conditions | 2 |
| Paths | 2 |
| Total Lines | 12 |
| Code Lines | 6 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 0 |
| CRAP Score | 6 |
| Changes | 0 | ||
| 1 | <?php |
||
| 19 | function get_signer(string $algorithm): Signer |
||
| 20 | { |
||
| 21 | $map = [ |
||
| 22 | 'HS256' => new Signer\Hmac\Sha256(), |
||
| 23 | 'RS512' => new Signer\Rsa\Sha512(), |
||
| 24 | ]; |
||
| 25 | |||
| 26 | if (!isset($map[$algorithm])) { |
||
| 27 | throw new \InvalidArgumentException(\sprintf('Invalid algorithm %s.', $algorithm)); |
||
| 28 | } |
||
| 29 | |||
| 30 | return $map[$algorithm]; |
||
| 31 | } |
||
| 32 |