1 | <?php |
||
12 | class Https |
||
13 | { |
||
14 | use Utils\RedirectTrait; |
||
15 | |||
16 | const HEADER = 'Strict-Transport-Security'; |
||
17 | |||
18 | /** |
||
19 | * @param int One year by default |
||
20 | */ |
||
21 | private $maxAge = 31536000; |
||
22 | |||
23 | /** |
||
24 | * @param bool Whether include subdomains |
||
25 | */ |
||
26 | private $includeSubdomains = false; |
||
27 | |||
28 | /** |
||
29 | * Set basic config. |
||
30 | */ |
||
31 | public function __construct() |
||
35 | |||
36 | /** |
||
37 | * Configure the max-age HSTS in seconds. |
||
38 | * |
||
39 | * @param int $maxAge |
||
40 | * |
||
41 | * @return self |
||
42 | */ |
||
43 | public function maxAge($maxAge) |
||
49 | |||
50 | /** |
||
51 | * Configure the includeSubDomains HSTS directive. |
||
52 | * |
||
53 | * @param bool $includeSubdomains |
||
54 | * |
||
55 | * @return self |
||
56 | */ |
||
57 | public function includeSubdomains($includeSubdomains = true) |
||
63 | |||
64 | /** |
||
65 | * Execute the middleware. |
||
66 | * |
||
67 | * @param RequestInterface $request |
||
68 | * @param ResponseInterface $response |
||
69 | * @param callable $next |
||
70 | * |
||
71 | * @return ResponseInterface |
||
72 | */ |
||
73 | public function __invoke(RequestInterface $request, ResponseInterface $response, callable $next) |
||
87 | } |
||
88 |