Failed Conditions
Pull Request — master (#125)
by Florent
21:10
created

OAuth2MessageMiddleware::process()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 8
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 5
nc 2
nop 2
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * The MIT License (MIT)
7
 *
8
 * Copyright (c) 2014-2018 Spomky-Labs
9
 *
10
 * This software may be modified and distributed under the terms
11
 * of the MIT license.  See the LICENSE file for details.
12
 */
13
14
namespace OAuth2Framework\Component\Core\Middleware;
15
16
use Psr\Http\Server\RequestHandlerInterface;
17
use Psr\Http\Server\MiddlewareInterface;
18
use OAuth2Framework\Component\Core\Message\OAuth2Message;
19
use OAuth2Framework\Component\Core\Message\OAuth2MessageFactoryManager;
20
use Psr\Http\Message\ResponseInterface;
21
use Psr\Http\Message\ServerRequestInterface;
22
23
final class OAuth2MessageMiddleware implements MiddlewareInterface
24
{
25
    /**
26
     * @var OAuth2MessageFactoryManager
27
     */
28
    private $auth2messageFactoryManager;
29
30
    /**
31
     * OAuth2ResponseMiddleware constructor.
32
     *
33
     * @param OAuth2MessageFactoryManager $auth2messageFactoryManager
34
     */
35
    public function __construct(OAuth2MessageFactoryManager $auth2messageFactoryManager)
36
    {
37
        $this->auth2messageFactoryManager = $auth2messageFactoryManager;
38
    }
39
40
    /**
41
     * {@inheritdoc}
42
     */
43
    public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
44
    {
45
        try {
46
            return $handler->handle($request);
47
        } catch (OAuth2Message $e) {
48
            return $oauth2Response = $this->auth2messageFactoryManager->getResponse($e);
0 ignored issues
show
Unused Code introduced by
$oauth2Response 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...
49
        }
50
    }
51
}
52