<commit_before><?php
namespace sbnc\addons;

use sbnc\Sbnc;

/**
 * Class Flasher
 *
 * Uses the util FlashMessages to flash errors and the request to the session.
 *
 * @package sbnc\addons
 */
class Flasher extends Addon implements AddonInterface
{

    ######################################################################################
    #########################           CONFIGURATION            #########################
    ######################################################################################

    /**
     * May be disabled if any inconsistencies occur
     *
     * @var bool Enable or disable module
     */
    protected $enabled = true;

    /**
     * set if there should be a redirect on error/success
     * add a url to be redirected at the second value like this:
     *
     * 'redirect:error' => 'http://example.com/about/contact'
     * 'redirect:success' => 'http://example.com/about/contact'
     *
     * set to false to disable redirecting or leave empty to redirect back to
     * the requesting url.
     *
     * SET AN EXPLICIT REDIRECT FOR SECURITY REASONS!
     *
     * @var array Options
     */
    protected $options = [
        'redirect:error' => '',
        'redirect:success' => ''
    ];

    ######################################################################################
    ######################################################################################

    private $flash;

    protected function init()
    {
        if (!$this->isEnabled()) return;

        if (Sbnc::utilExists('FlashMessages')) {
            $this->enabled = Sbnc::util('FlashMessages')->isEnabled();
            $this->flash = Sbnc::util('FlashMessages');
        }
    }

    public function __destruct()
    {
        if (!$this->isEnabled()) return;

        $errors = Sbnc::errors();
        if ((!empty($errors) && $this->options['redirect:error'] === false) ||
            (empty($errors) && $this->options['redirect:success'] === false)
        ) {
            $this->flash->flush('flasher');
        }
    }

    public function after()
    {
        if (!$this->isEnabled()) return;
<commit_msg>bug fix<commit_after><?php
namespace sbnc\addons;

use sbnc\Sbnc;

/**
 * Class Flasher
 *
 * Uses the util FlashMessages to flash errors and the request to the session.
 *
 * @package sbnc\addons
 */
class Flasher extends Addon implements AddonInterface
{

    ######################################################################################
    #########################           CONFIGURATION            #########################
    ######################################################################################

    /**
     * May be disabled if any inconsistencies occur
     *
     * @var bool Enable or disable module
     */
    protected $enabled = true;

    /**
     * set if there should be a redirect on error/success
     * add a url to be redirected at the second value like this:
     *
     * 'redirect:error' => 'http://example.com/about/contact'
     * 'redirect:success' => 'http://example.com/about/contact'
     *
     * set to false to disable redirecting or leave empty to redirect back to
     * the requesting url.
     *
     * SET AN EXPLICIT REDIRECT FOR SECURITY REASONS!
     *
     * @var array Options
     */
    protected $options = [
        'redirect:error' => '',
        'redirect:success' => ''
    ];

    ######################################################################################
    ######################################################################################

    private $flash;

    protected function init()
    {
        if (!$this->isEnabled()) return;

        if (Sbnc::utilExists('FlashMessages')) {
            $this->enabled = Sbnc::util('FlashMessages')->isEnabled();
            $this->flash = Sbnc::util('FlashMessages');
        } else {
            $this->enabled = false;
        }
    }

    public function __destruct()
    {
        if (!$this->isEnabled()) return;

        $errors = Sbnc::errors();
        if ((!empty($errors) && $this->options['redirect:error'] === false) ||
            (empty($errors) && $this->options['redirect:success'] === false)
        ) {
            $this->flash->flush('flasher');
        }
    }

    public function after()
    {
        if (!$this->isEnabled()) return;

{'fraction_non_alphanumeric': 0.2916380297823597, 'fraction_numerical': 0.0, 'mean_word_length': 2.7670405522001724, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 32, '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': '305000', 'n_tokens_mistral': 1134, 'n_tokens_neox': 1071, 'n_words': 276}