PHP Classes

File: src/Exception/TokenIndexNotInSessionException.php

Recommend this page to a friend!
  Packages of Scott Arciszewski   Anti-CSRF   src/Exception/TokenIndexNotInSessionException.php   Download  
File: src/Exception/TokenIndexNotInSessionException.php
Role: Class source
Content type: text/plain
Description: Class source
Class: Anti-CSRF
Generate tokens to protect against CSRF exploits
Author: By
Last change:
Date: 9 months ago
Size: 766 bytes
 

Contents

Class file image Download
<?php
declare(strict_types=1);

namespace
ParagonIE\AntiCSRF\Exception;

/**
 * Class TokenIndexNotInSessionException
 *
 * @package ParagonIE\AntiCSRF
 */
class TokenIndexNotInSessionException extends AntiCSRFException
{
    const
CODE_NATIVE = 1;
    const
CODE_CONSTRUCTOR = 2;

    public static function
fromNative(string $sessionIndex): self
   
{
        return new
self(
            \
sprintf('Token not found in native $_SESSION at index "%s"', $sessionIndex),
           
self::CODE_NATIVE
       
);
    }

    public static function
fromConstructor(string $sessionIndex): self
   
{
        return new
self(
            \
sprintf('Token not found in constructor session at index "%s"', $sessionIndex),
           
self::CODE_CONSTRUCTOR
       
);
    }
}