<commit_before><?php

namespace AdBar;

use Interop\Container\ContainerInterface as Container;
use Psr\Http\Message\ServerRequestInterface as Request;
use Psr\Http\Message\ResponseInterface as Response;

/**
 * Session Middleware
 *
 * This middleware class starts a secure session and encrypts it if encryption key is set.
 * Session cookie path, domain and secure values are configured automatically by default.
 * Session helper class will be injected to application container.
 */
class SessionMiddleware
{
    /** @var object Application container */
    protected $container;

    /** @var array Default settings */
    protected $settings = [

        // Session cookie settings
        'name'           => 'slim_session',
        'lifetime'       => 1440,
        'path'           => '/',
        'domain'         => null,
        'secure'         => false,
        'httponly'       => true,

        // Set session cookie path, domain and secure automatically
        'cookie_autoset' => true,

        // Path where session files are stored, PHP's default path will be used if set null
        'save_path'      => null,

        // Session cache limiter
        'cache_limiter'  => 'nocache',

        // Extend session lifetime after each user activity
        'autorefresh'    => false,

        // Encrypt session data if string is string is set
        'encryption_key' => null,

        // Session namespace
        'namespace'      => 'slim_app'
    ];

    /**
     * Constructor
     *
     * @param Container $container Container
     * @param array     $settings  Session settings
     */
    public function __construct(Container $container, array $settings = [])
    {
        $this->container = $container;
        $this->settings = array_merge($this->settings, $settings);
    }

    /**
     * Invoke middleware
     *
     * @param  Request  $request  PSR7 request
     * @param  Response $response PSR7 response
     * @param  callable $next     Next middleware
     * @return ResponseInterface
     */
    public function __invoke(Request $request, Response $response, callable $next)
    {
        // Get settings from request
        if ($this->settings['cookie_autoset'] === true) {
            $this->settings['path']   = $request->getUri()->getBasePath() . '/';<commit_msg>Removed settings injection from constructor.<commit_after><?php

namespace AdBar;

use Interop\Container\ContainerInterface as Container;
use Psr\Http\Message\ServerRequestInterface as Request;
use Psr\Http\Message\ResponseInterface as Response;

/**
 * Session Middleware
 *
 * This middleware class starts a secure session and encrypts it if encryption key is set.
 * Session cookie path, domain and secure values are configured automatically by default.
 * Session helper class will be injected to application container.
 */
class SessionMiddleware
{
    /** @var object Application container */
    protected $container;

    /** @var array Default settings */
    protected $settings = [

        // Session cookie settings
        'name'           => 'slim_session',
        'lifetime'       => 1440,
        'path'           => '/',
        'domain'         => null,
        'secure'         => false,
        'httponly'       => true,

        // Set session cookie path, domain and secure automatically
        'cookie_autoset' => true,

        // Path where session files are stored, PHP's default path will be used if set null
        'save_path'      => null,

        // Session cache limiter
        'cache_limiter'  => 'nocache',

        // Extend session lifetime after each user activity
        'autorefresh'    => false,

        // Encrypt session data if string is string is set
        'encryption_key' => null,

        // Session namespace
        'namespace'      => 'slim_app'
    ];

    /**
     * Constructor
     *
     * @param Container $container Container
     */
    public function __construct(Container $container)
    {
        if (is_array($container->settings['session'])) {
            $this->settings = array_merge($this->settings, $container->settings['session']);
        }
        $this->container = $container;
    }

    /**
     * Invoke middleware
     *
     * @param  Request  $request  PSR7 request
     * @param  Response $response PSR7 response
     * @param  callable $next     Next middleware
     * @return ResponseInterface
     */
    public function __invoke(Request $request, Response $response, callable $next)
    {
        // Get settings from request
        if ($this->settings['cookie_autoset'] === true) {
            $this->settings['path']   = $request->getUri()->getBasePath() . '/';
{'fraction_non_alphanumeric': 0.10553410553410554, 'fraction_numerical': 0.002574002574002574, 'mean_word_length': 2.288434414668547, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 43, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '741512', 'n_tokens_mistral': 1220, 'n_tokens_neox': 1193, 'n_words': 387}