Completed
Push — master ( 367e9f...6db52c )
by Sébastien
02:11
created

JwtAuthMiddlewareFactory   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
wmc 1
lcom 0
cbo 2
dl 0
loc 32
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
B __invoke() 0 24 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Soluble\Wallit\Middleware;
6
7
use Lcobucci\JWT\Signer\Hmac\Sha256;
8
use Psr\Container\ContainerInterface;
9
use Soluble\Wallit\Service\JwtService;
10
11
class JwtAuthMiddlewareFactory
12
{
13
    /**
14
     * @param ContainerInterface $container
15
     *
16
     * @return JwtAuthMiddleware
17
     */
18
    public function __invoke(ContainerInterface $container): JwtAuthMiddleware
19
    {
20
        $options = [
0 ignored issues
show
Unused Code introduced by
$options is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
21
            'secure'     => true, // Check for https
22
            'relaxed'    => [],
23
            'signer'     => new Sha256(),
24
            'privateKey' => 'private-key', // my super secret key
25
            /*
26
            'jwtStorage' => [
27
                HttpCookieStorage::class => [
28
                    'name' => 'jwtcookie',
29
                    'path' => '/',
30
                    //"httponly" => true,
31
                    //"secure" => true
32
                ],
33
                HttpAuthBearerStorage::class
34
            ],*/
35
            'attribute' => JwtAuthMiddleware::class, // request attribute
36
        ];
37
38
        $jwtService = new JwtService(new Sha256(), 'private-key');
39
40
        return new JwtAuthMiddleware($jwtService);
41
    }
42
}
43