Failed Conditions
Push — v7 ( 477009...5356df )
by Florent
03:33
created

JWKSetController   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 1
dl 0
loc 39
rs 10
c 0
b 0
f 0

2 Methods

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