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

FastlyCacheControlHeaderSetter   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 9
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 4
c 0
b 0
f 0
dl 0
loc 9
rs 10
wmc 2
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