JwtProvider::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 3
rs 10
1
<?php
2
3
namespace App\Mercure;
4
5
use Lcobucci\JWT\Builder;
6
use Lcobucci\JWT\Signer\Hmac\Sha256;
7
use Lcobucci\JWT\Signer\Key;
8
9
final class JwtProvider
10
{
11
    private $secret;
12
13
    public function __construct(string $secret)
14
    {
15
        $this->secret = $secret;
16
    }
17
18
    public function __invoke(): string
19
    {
20
        return (new Builder())
21
            ->withClaim('mercure', ['publish' => ['*']])
22
            ->getToken(new Sha256(), new Key($this->secret));
23
    }
24
}
25