<commit_before><?php

declare(strict_types=1);

namespace Cortex\Foundation\Providers;

use Illuminate\Routing\Router;
use Illuminate\Support\Collection;
use Illuminate\Pagination\Paginator;
use Illuminate\Support\Facades\Schema;
use Illuminate\Support\ServiceProvider;
use Rinvex\Support\Traits\ConsoleTools;
use Illuminate\Database\Schema\Blueprint;
use Cortex\Foundation\Models\ImportRecord;
use Cortex\Foundation\Models\AbstractModel;
use Illuminate\Contracts\Events\Dispatcher;
use Illuminate\View\Compilers\BladeCompiler;
use Cortex\Foundation\Http\Middleware\Clockwork;
use Cortex\Foundation\Generators\LangJsGenerator;
use Cortex\Foundation\Console\Commands\SeedCommand;
use Illuminate\Database\Eloquent\Relations\Relation;
use Cortex\Foundation\Console\Commands\InstallCommand;
use Cortex\Foundation\Console\Commands\MigrateCommand;
use Cortex\Foundation\Console\Commands\PublishCommand;
use Cortex\Foundation\Console\Commands\CoreSeedCommand;
use Cortex\Foundation\Console\Commands\RollbackCommand;
use Illuminate\Support\Facades\Session as SessionFacade;
use Cortex\Foundation\Console\Commands\CoreUnloadCommand;
use Cortex\Foundation\Verifiers\EloquentPresenceVerifier;
use Cortex\Foundation\Console\Commands\ExecuteDumpCommand;
use Cortex\Foundation\Console\Commands\CoreInstallCommand;
use Cortex\Foundation\Console\Commands\CoreMigrateCommand;
use Cortex\Foundation\Console\Commands\CorePublishCommand;
use Cortex\Foundation\Console\Commands\CoreActivateCommand;
use Cortex\Foundation\Console\Commands\CoreAutoloadCommand;
use Cortex\Foundation\Console\Commands\CoreRollbackCommand;
use Cortex\Foundation\Console\Commands\CoreDeactivateCommand;
use Cortex\Foundation\Http\Middleware\NotificationMiddleware;
use Cortex\Foundation\Overrides\Illuminate\Routing\Redirector;
use Cortex\Foundation\Overrides\Illuminate\Routing\UrlGenerator;
use Cortex\Foundation\Overrides\Barryvdh\Debugbar\DebugbarServiceProvider;
use Cortex\Foundation\Overrides\Mcamara\LaravelLocalization\LaravelLocalization;
use Cortex\Foundation\Overrides\Mariuzzo\LaravelJsLocalization\Commands\LangJsCommand;

class FoundationServiceProvider extends ServiceProvider
{
    use ConsoleTools;

    /**
     * The commands to be registered.
     *
     * @var array
     */
    protected $commands = [
        SeedCommand::class => 'command.cortex.foundation.seed',
        ExecuteDumpCommand::class => 'command.cortex.execute.dump',
        InstallCommand::class => 'command.cortex.foundation.install',
        MigrateCommand::class => 'command.cortex.foundation.migrate',
        PublishCommand::class => 'command.cortex.foundation.publish',
        RollbackCommand::class => 'command.cortex.foundation.rollback',
        CoreSeedCommand::class => 'command.cortex.foundation.coreseed',
        CoreInstallCommand::class => 'command.cortex.foundation.coreinstall',
        CoreMigrateCommand::class => 'command.cortex.foundation.coremigrate',
        CorePublishCommand::class => 'command.cortex.foundation.corempublish',
        CoreRollbackCommand::class => 'command.cortex.foundation.corerollback',
        CoreActivateCommand::class => 'command.cortex.foundation.coreactivate',
        CoreAutoloadCommand::class => 'command.cortex.foundation.coreautoload',
        CoreDeactivateCommand::class => 'command.cortex.foundation.coredeactivate',
        CoreUnloadCommand::class => 'command.cortex.foundation.coreunload',
    ];

    /**
     * Register any application services.
     *
     * This service provider is a great spot to register your various container
     * bindings with the application. As you can see, we are registering our
     * "Registrar" implementation here. You can add your own bindings too!
     *
     * @return void
     */
    public function register(): void
    {
        $this->overrideNotificationMiddleware();
        $this->overrideLaravelLocalization();
        $this->overrideUrlGenerator();
        $this->bindPresenceVerifier();
        $this->bindBlueprintMacro();
        $this->overrideRedirector();
        $this->bindBladeCompiler();
        $this->overrideLangJS();

        // Bind eloquent models to IoC container
        $this->app->singleton('cortex.foundation.import_record', $importerModel = $this->app['config']['cortex.foundation.models.import_record']);
        $importerModel === ImportRecord::class || $this->app->alias('cortex.foundation.import_record', ImportRecord::class);

        // Override datatables html builder
        $this->app->bind(\Yajra\DataTables\Html\Builder::class, \Cortex\Foundation\Overrides\Yajra\DataTables\Html\Builder::class);

        // Register console commands
        $this->registerCommands($this->commands);

        // Register dev service providers
        $this->app->environment('production') || $this->app->register(DebugbarServiceProvider::class);
    }

    /**
     * Bootstrap any application services.
     *
     * @return void
     */
    public function boot(Router $router, Dispatcher $dispatcher): void
    {
        // Fix the specified key was too long error
        Schema::defaultStringLength(191);

        // Use Pagination bootstrap styles
        Paginator::useBootstrap();

        // Override presence verifier<commit_msg>Simplify service provider model registration into IoC<commit_after><?php

declare(strict_types=1);

namespace Cortex\Foundation\Providers;

use Illuminate\Routing\Router;
use Illuminate\Support\Collection;
use Illuminate\Pagination\Paginator;
use Illuminate\Support\Facades\Schema;
use Illuminate\Support\ServiceProvider;
use Rinvex\Support\Traits\ConsoleTools;
use Illuminate\Database\Schema\Blueprint;
use Cortex\Foundation\Models\ImportRecord;
use Cortex\Foundation\Models\AbstractModel;
use Illuminate\Contracts\Events\Dispatcher;
use Illuminate\View\Compilers\BladeCompiler;
use Cortex\Foundation\Http\Middleware\Clockwork;
use Cortex\Foundation\Generators\LangJsGenerator;
use Cortex\Foundation\Console\Commands\SeedCommand;
use Illuminate\Database\Eloquent\Relations\Relation;
use Cortex\Foundation\Console\Commands\InstallCommand;
use Cortex\Foundation\Console\Commands\MigrateCommand;
use Cortex\Foundation\Console\Commands\PublishCommand;
use Cortex\Foundation\Console\Commands\CoreSeedCommand;
use Cortex\Foundation\Console\Commands\RollbackCommand;
use Illuminate\Support\Facades\Session as SessionFacade;
use Cortex\Foundation\Console\Commands\CoreUnloadCommand;
use Cortex\Foundation\Verifiers\EloquentPresenceVerifier;
use Cortex\Foundation\Console\Commands\ExecuteDumpCommand;
use Cortex\Foundation\Console\Commands\CoreInstallCommand;
use Cortex\Foundation\Console\Commands\CoreMigrateCommand;
use Cortex\Foundation\Console\Commands\CorePublishCommand;
use Cortex\Foundation\Console\Commands\CoreActivateCommand;
use Cortex\Foundation\Console\Commands\CoreAutoloadCommand;
use Cortex\Foundation\Console\Commands\CoreRollbackCommand;
use Cortex\Foundation\Console\Commands\CoreDeactivateCommand;
use Cortex\Foundation\Http\Middleware\NotificationMiddleware;
use Cortex\Foundation\Overrides\Illuminate\Routing\Redirector;
use Cortex\Foundation\Overrides\Illuminate\Routing\UrlGenerator;
use Cortex\Foundation\Overrides\Barryvdh\Debugbar\DebugbarServiceProvider;
use Cortex\Foundation\Overrides\Mcamara\LaravelLocalization\LaravelLocalization;
use Cortex\Foundation\Overrides\Mariuzzo\LaravelJsLocalization\Commands\LangJsCommand;

class FoundationServiceProvider extends ServiceProvider
{
    use ConsoleTools;

    /**
     * The commands to be registered.
     *
     * @var array
     */
    protected $commands = [
        SeedCommand::class => 'command.cortex.foundation.seed',
        ExecuteDumpCommand::class => 'command.cortex.execute.dump',
        InstallCommand::class => 'command.cortex.foundation.install',
        MigrateCommand::class => 'command.cortex.foundation.migrate',
        PublishCommand::class => 'command.cortex.foundation.publish',
        RollbackCommand::class => 'command.cortex.foundation.rollback',
        CoreSeedCommand::class => 'command.cortex.foundation.coreseed',
        CoreInstallCommand::class => 'command.cortex.foundation.coreinstall',
        CoreMigrateCommand::class => 'command.cortex.foundation.coremigrate',
        CorePublishCommand::class => 'command.cortex.foundation.corempublish',
        CoreRollbackCommand::class => 'command.cortex.foundation.corerollback',
        CoreActivateCommand::class => 'command.cortex.foundation.coreactivate',
        CoreAutoloadCommand::class => 'command.cortex.foundation.coreautoload',
        CoreDeactivateCommand::class => 'command.cortex.foundation.coredeactivate',
        CoreUnloadCommand::class => 'command.cortex.foundation.coreunload',
    ];

    /**
     * Register any application services.
     *
     * This service provider is a great spot to register your various container
     * bindings with the application. As you can see, we are registering our
     * "Registrar" implementation here. You can add your own bindings too!
     *
     * @return void
     */
    public function register(): void
    {
        $this->overrideNotificationMiddleware();
        $this->overrideLaravelLocalization();
        $this->overrideUrlGenerator();
        $this->bindPresenceVerifier();
        $this->bindBlueprintMacro();
        $this->overrideRedirector();
        $this->bindBladeCompiler();
        $this->overrideLangJS();

        // Bind eloquent models to IoC container
        $this->registerModels([
            'cortex.foundation.import_record' => ImportRecord::class,
        ]);

        // Override datatables html builder
        $this->app->bind(\Yajra\DataTables\Html\Builder::class, \Cortex\Foundation\Overrides\Yajra\DataTables\Html\Builder::class);

        // Register console commands
        $this->registerCommands($this->commands);

        // Register dev service providers
        $this->app->environment('production') || $this->app->register(DebugbarServiceProvider::class);
    }

    /**
     * Bootstrap any application services.
     *
     * @return void
     */
    public function boot(Router $router, Dispatcher $dispatcher): void
    {
        // Fix the specified key was too long error
        Schema::defaultStringLength(191);

        // Use Pagination bootstrap styles
        Paginator::useBootstrap();

        // Override presence verifier
{'fraction_non_alphanumeric': 0.10744041852354196, 'fraction_numerical': 0.0007750435962022863, 'mean_word_length': 4.323878287777204, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 72, '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': '663948', 'n_tokens_mistral': 2866, 'n_tokens_neox': 2887, 'n_words': 473}