ationMiddleware.php$0   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 6
Duplicated Lines 0 %

Coupling/Cohesion

Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 0
loc 6
c 0
b 0
f 0
wmc 1
cbo 0
ccs 2
cts 2
cp 1
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Chubbyphp\Security\Authentication;
6
7
use Chubbyphp\ErrorHandler\HttpException;
8
use Psr\Http\Message\ServerRequestInterface as Request;
9
use Psr\Http\Message\ResponseInterface as Response;
10
11
/**
12
 * @deprecated use AuthenticationErrorResponseMiddleware
13
 */
14
final class AuthenticationMiddleware
15
{
16
    /**
17
     * @var AuthenticationErrorHandlerInterface
18
     */
19
    private $middleware;
20
21
    /**
22
     * @param AuthenticationInterface $authentication
23
     */
24 1
    public function __construct(AuthenticationInterface $authentication)
25
    {
26 1
        $this->middleware = new AuthenticationErrorResponseMiddleware(
0 ignored issues
show
Documentation Bug introduced by
It seems like new \Chubbyphp\Security\...ponse, $code); } }) of type object<Chubbyphp\Securit...rrorResponseMiddleware> is incompatible with the declared type object<Chubbyphp\Securit...nErrorHandlerInterface> of property $middleware.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
27 1
            $authentication,
28
            new class() implements AuthenticationErrorHandlerInterface {
29 1
                public function errorResponse(Request $request, Response $response, int $code): Response
30
                {
31 1
                    throw HttpException::create($request, $response, $code);
32
                }
33
            }
34
        );
35 1
    }
36
37
    /**
38
     * @param Request       $request
39
     * @param Response      $response
40
     * @param callable|null $next
41
     *
42
     * @return Response
43
     *
44
     * @throws HttpException
45
     */
46 1
    public function __invoke(Request $request, Response $response, callable $next = null)
47
    {
48 1
        return $this->middleware->__invoke($request, $response, $next);
0 ignored issues
show
Bug introduced by
The method __invoke() does not seem to exist on object<Chubbyphp\Securit...nErrorHandlerInterface>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
49
    }
50
}
51