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