<commit_before><?php

namespace Coyote\Services\Session;

use Illuminate\Session\DatabaseSessionHandler;

class Handler extends DatabaseSessionHandler
{
    /**
     * {@inheritDoc}
     */
    public function write($sessionId, $data)
    {
        $userId  = auth()->check() ? auth()->user()->id : null;
        $url     = request()->fullUrl();
        $ip      = request()->ip();
        $browser = '';

        // nie korzystamy ze standardowej klasy Request. Testy funkcjonalne "nie widza"
        // metody browser() z klasy CostomRequest
        if (method_exists(request(), 'browser')) {
            $browser = request()->browser();
        }

        $data = [
            'payload'       => base64_encode($data),
            'updated_at'    => \DB::raw('NOW()'),
            'user_id'       => $userId,
            'url'           => $url,
            'ip'            => $ip,
            'browser'       => $browser
        ];

        if ($this->exists) {
            $this->getQuery()->where('id', $sessionId)->update($data);
        } else {
            $this->getQuery()->insert(['id' => $sessionId] + $data);
        }

        $this->exists = true;
    }

    /**
     * {@inheritdoc}
     */
    public function gc($lifetime)
    {
        $this->getQuery()->where('updated_at', '<=', \DB::raw("NOW() - INTERVAL '$lifetime seconds'"))->delete();
    }
}<commit_msg>rezygnacja z facade<commit_after><?php

namespace Coyote\Services\Session;

use Illuminate\Database\Query\Expression;
use Illuminate\Session\DatabaseSessionHandler;

class Handler extends DatabaseSessionHandler
{
    /**
     * {@inheritDoc}
     */
    public function write($sessionId, $data)
    {
        $request = $this->container->make('request');
        $auth    = $this->container->make('auth');

        $userId  = $auth->check() ? $auth->user()->id : null;
        $url     = $request->fullUrl();
        $ip      = $request->ip();
        $browser = '';

        // nie korzystamy ze standardowej klasy Request. Testy funkcjonalne "nie widza"
        // metody browser() z klasy CostomRequest
        if (method_exists($request, 'browser')) {
            $browser = $request->browser();
        }

        $data = [
            'payload'       => base64_encode($data),
            'updated_at'    => new Expression('NOW()'),
            'user_id'       => $userId,
            'url'           => $url,
            'ip'            => $ip,
            'browser'       => $browser
        ];

        if ($this->exists) {
            $this->getQuery()->where('id', $sessionId)->update($data);
        } else {
            $this->getQuery()->insert(['id' => $sessionId] + $data);
        }

        $this->exists = true;
    }

    /**
     * {@inheritdoc}
     */
    public function gc($lifetime)
    {
        $this->getQuery()->where('updated_at', '<=', new Expression("NOW() - INTERVAL '$lifetime seconds'"))->delete();
    }
}
{'fraction_non_alphanumeric': 0.17727583846680356, 'fraction_numerical': 0.0013689253935660506, 'mean_word_length': 1.8826429980276134, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 53, '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': '2247031', 'n_tokens_mistral': 866, 'n_tokens_neox': 856, 'n_words': 160}