NoCacheMiddleware::process()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 2
dl 0
loc 6
ccs 0
cts 3
cp 0
crap 2
rs 10
c 0
b 0
f 0
1
<?php declare(strict_types=1);
2
3
namespace Koded\Framework\Middleware;
4
5
use Psr\Http\Message\{ResponseInterface, ServerRequestInterface};
6
use Psr\Http\Server\{MiddlewareInterface, RequestHandlerInterface};
7
8
/**
9
 * @link https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cache-Control
10
 */
11
class NoCacheMiddleware implements MiddlewareInterface
12
{
13
    public function process(
14
        ServerRequestInterface $request,
15
        RequestHandlerInterface $handler): ResponseInterface
16
    {
17
        return $handler->handle($request)
0 ignored issues
show
Bug Best Practice introduced by
The expression return $handler->handle(... 'no-cache, max-age=0') returns the type Psr\Http\Message\MessageInterface which includes types incompatible with the type-hinted return Psr\Http\Message\ResponseInterface.
Loading history...
18
            ->withHeader('Cache-Control', 'no-cache, max-age=0');
19
    }
20
}
21