Failed Conditions
Push — v7 ( b348c3...69552d )
by Florent
02:00
created

JWKSetController::getAction()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 11
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 6
nc 1
nop 0
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * The MIT License (MIT)
7
 *
8
 * Copyright (c) 2014-2017 Spomky-Labs
9
 *
10
 * This software may be modified and distributed under the terms
11
 * of the MIT license.  See the LICENSE file for details.
12
 */
13
14
namespace Jose\Bundle\JoseFramework\Controller;
15
16
use Symfony\Component\HttpFoundation\Response;
17
18
/**
19
 * Class JWKSetController.
20
 */
21
final class JWKSetController
22
{
23
    /**
24
     * @var string
25
     */
26
    private $jwkset;
27
28
    /**
29
     * @var int
30
     */
31
    private $maxAge;
32
33
    /**
34
     * JWKSetController constructor.
35
     *
36
     * @param string $jwkset
37
     * @param int    $maxAge
38
     */
39
    public function __construct(string $jwkset, int $maxAge)
40
    {
41
        $this->jwkset = $jwkset;
42
        $this->maxAge = $maxAge;
43
    }
44
45
    /**
46
     * @return Response
47
     */
48
    public function getAction(): Response
49
    {
50
        return new Response(
51
            $this->jwkset,
52
            Response::HTTP_OK,
53
            [
54
                'Content-Type' => 'application/jwk-set+json; charset=UTF-8',
55
                'Cache-Control' => sprintf('public, max-age=%d, must-revalidate, no-transform', $this->maxAge),
56
            ]
57
        );
58
    }
59
}
60