| Conditions | 4 |
| Paths | 6 |
| Total Lines | 23 |
| Code Lines | 14 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 14 |
| CRAP Score | 4 |
| Changes | 0 | ||
| 1 | <?php |
||
| 21 | 3 | public function __invoke(ContainerInterface $container): JwtAuthMiddleware |
|
| 22 | { |
||
| 23 | 3 | $config = $container->has('config') ? $container->get('config') : []; |
|
| 24 | 3 | $options = $config[ConfigProvider::CONFIG_PREFIX][self::CONFIG_KEY] ?? null; |
|
| 25 | |||
| 26 | 3 | if (!is_array($options)) { |
|
| 27 | 1 | throw new ConfigException(sprintf( |
|
| 28 | 1 | "Missing or invalid entry ['%s']['%s'] in container configuration.", |
|
| 29 | 1 | ConfigProvider::CONFIG_PREFIX, |
|
| 30 | 1 | self::CONFIG_KEY) |
|
| 31 | ); |
||
| 32 | } |
||
| 33 | |||
| 34 | 2 | if (!$container->has(JwtService::class)) { |
|
| 35 | 1 | throw new ConfigException(sprintf( |
|
| 36 | 1 | "Cannot locate required '%s' from container, was it provided ?", |
|
| 37 | 1 | JwtService::class) |
|
| 38 | ); |
||
| 39 | } |
||
| 40 | |||
| 41 | 1 | return new JwtAuthMiddleware($options, |
|
| 42 | 1 | $container->get(JwtService::class)); |
|
| 43 | } |
||
| 44 | } |
||
| 45 |