<commit_before><?php
/**
 * Opulence
 *
 * @link      https://www.opulencephp.com
 * @copyright Copyright (C) 2015 <NAME>
 * @license   https://github.com/opulencephp/opulencephp.com/blob/master/LICENSE.md
 */
namespace OpulenceWebsite\Http\Middleware;

use DateTime;
use Opulence\Framework\Http\CsrfTokenChecker;
use Opulence\Framework\Http\Middleware\CheckCsrfToken as BaseMiddleware;
use Opulence\Http\Responses\Cookie;
use Opulence\Http\Responses\Response;

/**
 * Defines the middleware that checks the CSRF token
 */
class CheckCsrfToken extends BaseMiddleware
{
    /** @var array|null The config array */
    private $config = null;

    /**
     * Writes data to the response
     *
     * @param Response $response The response to write to
     * @return Response The response with the data written to it
     */
    protected function writeToResponse(Response $response) : Response
    {
        $this->loadConfig();
        // Add an XSRF cookie for JavaScript frameworks to use
        $response->getHeaders()->setCookie(
            new Cookie(
                "XSRF-TOKEN",
                $this->session->get(CSRFTokenChecker::TOKEN_INPUT_NAME),
                new DateTime("+{$this->config["xsrfcookie.lifetime"]} seconds"),
                $this->config["cookie.path"],
                $this->config["cookie.domain"],
                false,<commit_msg>Fixed typos<commit_after><?php
/**
 * Opulence
 *
 * @link      https://www.opulencephp.com
 * @copyright Copyright (C) 2015 <NAME>
 * @license   https://github.com/opulencephp/opulencephp.com/blob/master/LICENSE.md
 */
namespace OpulenceWebsite\Http\Middleware;

use DateTime;
use Opulence\Framework\Http\CsrfTokenChecker;
use Opulence\Framework\Http\Middleware\CheckCsrfToken as BaseMiddleware;
use Opulence\Http\Responses\Cookie;
use Opulence\Http\Responses\Response;

/**
 * Defines the middleware that checks the CSRF token
 */
class CheckCsrfToken extends BaseMiddleware
{
    /** @var array|null The config array */
    private $config = null;

    /**
     * Writes data to the response
     *
     * @param Response $response The response to write to
     * @return Response The response with the data written to it
     */
    protected function writeToResponse(Response $response) : Response
    {
        $this->loadConfig();
        // Add an XSRF cookie for JavaScript frameworks to use
        $response->getHeaders()->setCookie(
            new Cookie(
                "XSRF-TOKEN",
                $this->session->get(CsrfTokenChecker::TOKEN_INPUT_NAME),
                new DateTime("+{$this->config["xsrfcookie.lifetime"]} seconds"),
                $this->config["cookie.path"],
                $this->config["cookie.domain"],
                false,
{'fraction_non_alphanumeric': 0.11605839416058394, 'fraction_numerical': 0.00291970802919708, 'mean_word_length': 2.775482093663912, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 21, 'https://': 4, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2556028', 'n_tokens_mistral': 804, 'n_tokens_neox': 769, 'n_words': 188}