<commit_before><?php
namespace lo\plugins\plugins\helloworld;

use lo\plugins\BasePlugin;
use yii\helpers\ArrayHelper;
use yii\helpers\Html;
use yii\web\View;

/**
 * Plugin Name: Hello World
 * Plugin URI: https://github.com/loveorigami/yii2-plugins-system/tree/master/src/plugins/helloworld
 * Version: 1.7
 * Description: A simple hello world plugin
 * Author: <NAME>
 * Author URI: https://github.com/loveorigami
 */
class Helloworld extends BasePlugin
{
    /**
     * @var array
     */
    public static $config = [
        'search' => 'Hello, world!',
        'replace' => 'Hello, Yii!',
        'color' => '#FFDB51'
    ];

    /**
     * @return array
     */
    public static function events()
    {
        return [
            View::class => [
                View::EVENT_AFTER_RENDER => ['hello', self::$config]
            ]
        ];
    }

    /**
     * @param $event
     */
    public static function hello($event)
    {
        $search = ArrayHelper::getValue($event->data, 'search', self::$config['search']);
        $replace = ArrayHelper::getValue($event->data, 'replace', self::$config['replace']);
        $color = ArrayHelper::getValue($event->data, 'color', self::$config['color']);

        if (isset($event->output)) {
            $content = $event->output;
            $event->output = str_replace($search, Html::tag('span', $replace, [
                'style' => "background-color:$color;"
            ]), $content);
        }
    }
}<commit_msg>new event<commit_after><?php
namespace lo\plugins\plugins\helloworld;

use lo\plugins\BasePlugin;
use yii\helpers\ArrayHelper;
use yii\helpers\Html;
use yii\web\Response;

/**
 * Plugin Name: Hello World
 * Plugin URI: https://github.com/loveorigami/yii2-plugins-system/tree/master/src/plugins/helloworld
 * Version: 1.8
 * Description: A simple hello world plugin
 * Author: <NAME>
 * Author URI: https://github.com/loveorigami
 */
class Helloworld extends BasePlugin
{
    /**
     * @var array
     */
    public static $config = [
        'search' => 'Hello, world!',
        'replace' => 'Hello, Yii!',
        'color' => '#FFDB51'
    ];

    /**
     * @return array
     */
    public static function events()
    {
        return [
            Response::class => [
                Response::EVENT_AFTER_PREPARE => ['hello', self::$config]
            ]
        ];
    }

    /**
     * @param $event
     */
    public static function hello($event)
    {
        if (!$content = $event->sender->content) return;

        $search = ArrayHelper::getValue($event->data, 'search', self::$config['search']);
        $replace = ArrayHelper::getValue($event->data, 'replace', self::$config['replace']);
        $color = ArrayHelper::getValue($event->data, 'color', self::$config['color']);

        $event->sender->content = str_replace($search, Html::tag('span', $replace, [
            'style' => "background-color:$color;"
        ]), $content);
    }
}
{'fraction_non_alphanumeric': 0.17154526889040164, 'fraction_numerical': 0.0034036759700476512, 'mean_word_length': 2.5155502392344498, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 30, 'https://': 4, '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': '5270656', 'n_tokens_mistral': 899, 'n_tokens_neox': 886, 'n_words': 177}