Completed
Push — master ( aafa22...ae7595 )
by Alejandro
24s queued 12s
created

JwtConfigFactory   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 10
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 5
c 1
b 0
f 0
dl 0
loc 10
ccs 5
cts 5
cp 1
rs 10
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A __invoke() 0 8 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Shlinkio\Shlink\Common\Mercure;
6
7
use Lcobucci\JWT\Configuration;
8
use Lcobucci\JWT\Signer\Hmac\Sha256;
9
use Lcobucci\JWT\Signer\Key;
10
use Psr\Container\ContainerInterface;
11
use Shlinkio\Shlink\Common\Exception\MercureException;
12
13
class JwtConfigFactory
14
{
15 4
    public function __invoke(ContainerInterface $container): Configuration
16
    {
17 4
        $jwtSecret = $container->get('config')['mercure']['jwt_secret'] ?? null;
18 4
        if ($jwtSecret === null) {
19 3
            throw MercureException::missingJwtSecret();
20
        }
21
22 1
        return Configuration::forSymmetricSigner(new Sha256(), new Key((string) $jwtSecret));
23
    }
24
}
25