Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
1 / 1
n/a
0 / 0
CRAP
n/a
0 / 0
1<?php
2
3declare(strict_types=1);
4
5/** @license For full copyright and license information, please see the LICENSE.md file. */
6
7namespace App\Core\Security\Csrf;
8
9defined('AMMONLY_APP') || exit('Direct script access is forbidden.');
10
11/**
12 * CSRF Token Manager Contract.
13 *
14 * Defines methods for token generation, acquisition, validation, and renewal.
15 *
16 * @package App\Core\Security\Csrf
17 */
18interface CsrfTokenManagerInterface
19{
20    /**
21     * Retrieves or generates current valid CSRF token.
22     *
23     * @return string Active CSRF token string.
24     */
25    public function getToken(): string;
26
27    /**
28     * Validates submitted token against active session token.
29     *
30     * @param string|null $token Submitted candidate token.
31     * @return bool True if token matches securely, false otherwise.
32     */
33    public function validateToken(?string $token): bool;
34
35    /**
36     * Generates and returns a fresh CSRF token, invalidating the previous one.
37     *
38     * @return string Newly generated CSRF token.
39     */
40    public function regenerateToken(): string;
41}