Passed
Push — redis ( 437779 )
by Akihito
11:19
created

FastlyCacheControlHeaderSetter::__invoke()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 3
c 0
b 0
f 0
nc 2
nop 2
dl 0
loc 5
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace BEAR\QueryRepository\Cdn;
6
7
use BEAR\QueryRepository\CdnCacheControlHeaderSetterInterface;
8
use BEAR\Resource\ResourceObject;
9
10
use function sprintf;
11
12
final class FastlyCacheControlHeaderSetter implements CdnCacheControlHeaderSetterInterface
13
{
14
    public const CDN_CACHE_CONTROL_HEADER = 'Surrogate-Control';
15
16
    public function __invoke(ResourceObject $ro, int|null $sMaxAge): void
17
    {
18
        $sMaxAge ??= 31_536_000;
0 ignored issues
show
Bug introduced by
A parse error occurred: Syntax error, unexpected T_STRING on line 18 at column 23
Loading history...
19
        if (! isset($ro->headers[self::CDN_CACHE_CONTROL_HEADER])) {
20
            $ro->headers[self::CDN_CACHE_CONTROL_HEADER] = sprintf('max-age=%s', (string) $sMaxAge);
21
        }
22
    }
23
}
24