Passed
Push — main ( ed4306...4891af )
by Daniel
04:25
created

MiddlewareFactory::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 0

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 1
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 0
c 1
b 0
f 0
nc 1
nop 2
dl 0
loc 4
ccs 1
cts 1
cp 1
crap 1
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Uxmp\Core\Api\Lib\Middleware;
6
7
use Nyholm\Psr7\Factory\Psr17Factory;
8
use Psr\Http\Server\MiddlewareInterface;
9
use Psr\Log\LoggerInterface;
10
use Uxmp\Core\Component\Authentication\SessionManagerInterface;
11
12
/**
13
 * Creates the api middleware classes
14
 */
15
final class MiddlewareFactory implements MiddlewareFactoryInterface
16
{
17 2
    public function __construct(
18
        private readonly SessionManagerInterface $sessionManager,
19
        private readonly Psr17Factory $psr17Factory,
20
    ) {
21
    }
22
23 1
    public function createRequestLoggingMiddleware(
24
        LoggerInterface $logger
25
    ): MiddlewareInterface {
26 1
        return new RequestLoggingMiddleware(
27
            $logger
28
        );
29
    }
30
31 1
    public function createSessionValidatorMiddleware(): MiddlewareInterface
32
    {
33 1
        return new SessionValidatorMiddleware(
34 1
            $this->sessionManager,
35 1
            $this->psr17Factory,
36
        );
37
    }
38
}
39