| Conditions | 4 |
| Paths | 6 |
| Total Lines | 22 |
| Code Lines | 13 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 10 |
| CRAP Score | 4.1967 |
| Changes | 0 | ||
| 1 | <?php |
||
| 21 | 2 | public function __invoke(ContainerInterface $container): JwtAuthMiddleware |
|
| 22 | { |
||
| 23 | 2 | $config = $container->has('config') ? $container->get('config') : []; |
|
| 24 | 2 | $options = $config[ConfigProvider::CONFIG_PREFIX][self::CONFIG_KEY] ?? null; |
|
| 25 | |||
| 26 | 2 | 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 | 1 | if (!$container->has(JwtService::class)) { |
|
| 35 | throw new ConfigException(sprintf( |
||
| 36 | "Cannot locate '%s' from container, was it provided ?", |
||
| 37 | JwtService::class) |
||
| 38 | ); |
||
| 39 | } |
||
| 40 | |||
| 41 | 1 | return new JwtAuthMiddleware($container->get(JwtService::class), $options); |
|
| 42 | } |
||
| 43 | } |
||
| 44 |