TagRequest   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 10
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
eloc 3
c 1
b 0
f 0
dl 0
loc 10
ccs 4
cts 4
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A process() 0 3 1
A getRequestTag() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Yiisoft\Yii\Web\Middleware;
6
7
use Psr\Http\Message\ResponseInterface;
8
use Psr\Http\Message\ServerRequestInterface;
9
use Psr\Http\Server\MiddlewareInterface;
10
use Psr\Http\Server\RequestHandlerInterface;
11
12
/**
13
 * Tags request with a random value that could be later used for identifying it.
14
 */
15
final class TagRequest implements MiddlewareInterface
16
{
17 1
    public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
18
    {
19 1
        return $handler->handle($request->withAttribute('requestTag', $this->getRequestTag()));
20
    }
21
22 1
    private function getRequestTag(): string
23
    {
24 1
        return uniqid('', true);
25
    }
26
}
27