private function validateToken(string $formName, string $token): bool
    {
        $sortedCsrf = $this->getStoredCsrfToken($formName);
        if (!is_null($sortedCsrf)) {
            $csrfData = Session::getInstance()->read('__CSRF_TOKEN', []);
            if (is_null($this->request->getHeader('CSRF_KEEP_ALIVE'))
                && is_null($this->request->getParameter('CSRF_KEEP_ALIVE'))) {
                $csrfData[$formName] = '';
                Session::getInstance()->set('__CSRF_TOKEN', $csrfData);
            }
            return hash_equals($sortedCsrf, $token);
        }
        return false;
    }
private function validateToken(string $formName, string $token): bool
    {
        $sortedCsrf = $this->getStoredCsrfToken($formName);
        if (!is_null($sortedCsrf)) {
            $csrfData = Session::getInstance()->read('__CSRF_TOKEN', []);
            if (is_null($this->request->getHeader('CSRF_KEEP_ALIVE'))
                && is_null($this->request->getParameter('CSRF_KEEP_ALIVE'))) {
                $csrfData[$formName] = '';
                Session::getInstance()->set('__CSRF_TOKEN', $csrfData);
            }
            return hash_equals($sortedCsrf, $token);
        }
        return false;
    }
private function validateToken ( string $ formName , string $ token ) : bool { $ sortedCsrf = $ this -> getStoredCsrfToken ( $ formName ) ; if ( ! is_null ( $ sortedCsrf ) ) { $ csrfData = Session :: getInstance ( ) -> read ( '__CSRF_TOKEN' , [ ] ) ; if ( is_null ( $ this -> request -> getHeader ( 'CSRF_KEEP_ALIVE' ) ) && is_null ( $ this -> request -> getParameter ( 'CSRF_KEEP_ALIVE' ) ) ) { $ csrfData [ $ formName ] = '' ; Session :: getInstance ( ) -> set ( '__CSRF_TOKEN' , $ csrfData ) ; } return hash_equals ( $ sortedCsrf , $ token ) ; } return false ; }
Validates the given token with the one stored for the specified form
name. Once validated, good or not, the token is removed from the
session.

@param $formName
@param $token
@return bool
Validates the given token with the one stored for the specified form name . Once validated good or not the token is removed from the session .