Passed
Push — master ( a6d59a...971523 )
by butschster
16:28 queued 13s
created

AuthTransportWithStorageMiddleware::process()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 3
ccs 2
cts 2
cp 1
rs 10
cc 1
nc 1
nop 2
crap 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Spiral\Auth\Middleware;
6
7
use Psr\EventDispatcher\EventDispatcherInterface;
8
use Psr\Http\Message\ResponseInterface;
9
use Psr\Http\Message\ServerRequestInterface;
10
use Psr\Http\Server\MiddlewareInterface;
11
use Psr\Http\Server\RequestHandlerInterface;
12
use Spiral\Auth\ActorProviderInterface;
13
use Spiral\Auth\TokenStorageProviderInterface;
14
use Spiral\Auth\TransportRegistry;
15
use Spiral\Core\ScopeInterface;
16
17
/**
18
 * Auth by specific transport.
19
 */
20
final class AuthTransportWithStorageMiddleware implements MiddlewareInterface
21
{
22
    private readonly MiddlewareInterface $authMiddleware;
23
24 1
    public function __construct(
25
        string $transportName,
26
        ScopeInterface $scope,
27
        ActorProviderInterface $actorProvider,
28
        TokenStorageProviderInterface $tokenStorageProvider,
29
        TransportRegistry $transportRegistry,
30
        ?EventDispatcherInterface $eventDispatcher = null,
31
        ?string $storage = null
32
    ) {
33 1
        $this->authMiddleware = new AuthTransportMiddleware(
0 ignored issues
show
Bug introduced by
The property authMiddleware is declared read-only in Spiral\Auth\Middleware\A...rtWithStorageMiddleware.
Loading history...
34
            $transportName,
35
            $scope,
36
            $actorProvider,
37 1
            $tokenStorageProvider->getStorage($storage),
38
            $transportRegistry,
39
            $eventDispatcher
40
        );
41
    }
42
43
    /**
44
     * @throws \Throwable
45
     */
46 1
    public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
47
    {
48 1
        return $this->authMiddleware->process($request, $handler);
49
    }
50
}
51