<commit_before><?php

namespace Meebio\PhpEvalConsole\Providers;

use Illuminate\Routing\Router;
use Illuminate\Support\ServiceProvider;
use Meebio\PhpEvalConsole\Authorizers\IpAuthorizer;
use Meebio\PhpEvalConsole\Console;
use Meebio\PhpEvalConsole\Evaluators\EvalEvaluator;

class PhpEvalConsoleLaravelServiceProvider extends ServiceProvider
{
    /**
     * Register the service provider.
     *
     * @return void
     */
    public function register()
    {
        $this->app->singleton(Console::class, function ($app) {
            return new Console($this->consoleConfig());
        });
    }

    /**
     * Perform post-registration booting of services.
     *
     * @return void
     */
    public function boot()
    {
        $this->app['db']->connection()->enableQueryLog();

        $this->publishes([
            __DIR__ . '/../../assets' => public_path('vendor/console'),
        ], 'public');

        if (!$this->app->routesAreCached()) {
            $this->app['router']->get(
                'console',
                [
                    'as' => 'phpEvalConsole.view',
                    function (Console $console) {
                        $console->renderView();
                    },
                ]
            );

            $this->app['router']->post(
                'console',
                [
                    'as' => 'phpEvalConsole.execute',
                    function (Console $console) {
                        $console->execute();
                    },
                ]
            );
        }
    }

    /**
     * @return array
     */
    protected function consoleConfig()
    {
        return [
            'assets_dir'       => asset('vendor/console'),
            'execute_url'      => route('phpEvalConsole.execute'),
            'evaluator'        => new EvalEvaluator(),
            'authorizer'       => new IpAuthorizer(['::1', '127.0.0.1']),
            'queries_callback' => function () {
                return $this->queriesCallback();
            },
        ];
    }

    /**
     * @return array
     */<commit_msg>Update of assets path.<commit_after><?php

namespace Meebio\PhpEvalConsole\Providers;

use Illuminate\Routing\Router;
use Illuminate\Support\ServiceProvider;
use Meebio\PhpEvalConsole\Authorizers\IpAuthorizer;
use Meebio\PhpEvalConsole\Console;
use Meebio\PhpEvalConsole\Evaluators\EvalEvaluator;

class PhpEvalConsoleLaravelServiceProvider extends ServiceProvider
{
    /**
     * Register the service provider.
     *
     * @return void
     */
    public function register()
    {
        $this->app->singleton(Console::class, function ($app) {
            return new Console($this->consoleConfig());
        });
    }

    /**
     * Perform post-registration booting of services.
     *
     * @return void
     */
    public function boot()
    {
        $this->app['db']->connection()->enableQueryLog();

        $this->publishes([
            __DIR__ . '/../../assets' => public_path('vendor/php-eval-console'),
        ], 'public');

        if (!$this->app->routesAreCached()) {
            $this->app['router']->get(
                'console',
                [
                    'as' => 'phpEvalConsole.view',
                    function (Console $console) {
                        $console->renderView();
                    },
                ]
            );

            $this->app['router']->post(
                'console',
                [
                    'as' => 'phpEvalConsole.execute',
                    function (Console $console) {
                        $console->execute();
                    },
                ]
            );
        }
    }

    /**
     * @return array
     */
    protected function consoleConfig()
    {
        return [
            'assets_dir'       => asset('vendor/php-eval-console'),
            'execute_url'      => route('phpEvalConsole.execute'),
            'evaluator'        => new EvalEvaluator(),
            'authorizer'       => new IpAuthorizer(['::1', '127.0.0.1']),
            'queries_callback' => function () {
                return $this->queriesCallback();
            },
        ];
    }

    /**
     * @return array
     */
{'fraction_non_alphanumeric': 0.14007134363852555, 'fraction_numerical': 0.0033293697978596906, 'mean_word_length': 1.4961424332344213, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 51, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, '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': '3014986', 'n_tokens_mistral': 1148, 'n_tokens_neox': 1113, 'n_words': 181}