<commit_before><?php

namespace Spatie\MediaLibrary;

use Illuminate\Contracts\Foundation\Application;
use Illuminate\Support\ServiceProvider;
use Spatie\MediaLibrary\Commands\RegenerateCommand;
use Spatie\MediaLibrary\UrlGenerator\UrlGenerator;

class MediaLibraryServiceProvider extends ServiceProvider
{
    /**
     * Indicates if loading of the provider is deferred.
     *
     * @var bool
     */
    protected $defer = false;

    /**
     * Bootstrap the application events.
     */
    public function boot()
    {
        Media::observe(new MediaObserver());

        $this->publishes([
            __DIR__.'/../resources/config/laravel-medialibrary.php' => $this->app->configPath().'/'.'laravel-medialibrary.php',
        ], 'config');

        if (!class_exists('CreateMediaTable')) {

            // Publish the migration
            $timestamp = date('Y_m_d_His', time());

            $this->publishes([
                __DIR__.'/../resources/migrations/create_media_table.php.stub' => $this->app->basePath().'/'.'database/migrations/'.$timestamp.'_create_media_table.php',
            ], 'migrations');
        }
    }

    /**
     * Register the service provider.
     */
    public function register()
    {
        $this->mergeConfigFrom(__DIR__.'/../resources/config/laravel-medialibrary.php', 'laravel-medialibrary');

        $this->app->bind(Filesystem::class, function (Application $app) {
            return new Filesystem($this->app->filesystem->disk($app->config->get('laravel-medialibrary.filesystem')), $app->config);
        });

        $this->app->bind(UrlGenerator::class, function (Application $app) {
            $urlGeneratorClass = 'Spatie\MediaLibrary\UrlGenerator\\'.ucfirst($this->getDriverType()).'UrlGenerator';

            $customClass = $app->config->get('laravel-medialibrary.custom_url_generator_class');

            if ($customClass != '' && class_exists($customClass) && $customClass instanceof UrlGenerator) {
                $urlGeneratorClass = $customClass;
            }

            return $this->app->make($urlGeneratorClass);
        });

        $this->app->singleton(MediaRepository::class);

        $this->app['command.medialibrary:regenerate'] = $this->app->make(RegenerateCommand::class);

        $this->commands(['command.medialibrary:regenerate']);
    }

    /**
     * @return string
     */
    public function getDriverType()<commit_msg>instanceof not working with strings.<commit_after><?php

namespace Spatie\MediaLibrary;

use Illuminate\Contracts\Foundation\Application;
use Illuminate\Support\ServiceProvider;
use Spatie\MediaLibrary\Commands\RegenerateCommand;
use Spatie\MediaLibrary\UrlGenerator\UrlGenerator;

class MediaLibraryServiceProvider extends ServiceProvider
{
    /**
     * Indicates if loading of the provider is deferred.
     *
     * @var bool
     */
    protected $defer = false;

    /**
     * Bootstrap the application events.
     */
    public function boot()
    {
        Media::observe(new MediaObserver());

        $this->publishes([
            __DIR__.'/../resources/config/laravel-medialibrary.php' => $this->app->configPath().'/'.'laravel-medialibrary.php',
        ], 'config');

        if (!class_exists('CreateMediaTable')) {

            // Publish the migration
            $timestamp = date('Y_m_d_His', time());

            $this->publishes([
                __DIR__.'/../resources/migrations/create_media_table.php.stub' => $this->app->basePath().'/'.'database/migrations/'.$timestamp.'_create_media_table.php',
            ], 'migrations');
        }
    }

    /**
     * Register the service provider.
     */
    public function register()
    {
        $this->mergeConfigFrom(__DIR__.'/../resources/config/laravel-medialibrary.php', 'laravel-medialibrary');

        $this->app->bind(Filesystem::class, function (Application $app) {
            return new Filesystem($this->app->filesystem->disk($app->config->get('laravel-medialibrary.filesystem')), $app->config);
        });

        $this->app->bind(UrlGenerator::class, function (Application $app) {
            $urlGeneratorClass = 'Spatie\MediaLibrary\UrlGenerator\\'.ucfirst($this->getDriverType()).'UrlGenerator';

            $customClass = $app->config->get('laravel-medialibrary.custom_url_generator_class');

            if ($customClass != '' && class_exists($customClass) && is_subclass_of($customClass, UrlGenerator::class)) {
                $urlGeneratorClass = $customClass;
            }

            return $this->app->make($urlGeneratorClass);
        });

        $this->app->singleton(MediaRepository::class);

        $this->app['command.medialibrary:regenerate'] = $this->app->make(RegenerateCommand::class);

        $this->commands(['command.medialibrary:regenerate']);
    }

    /**
     * @return string
     */
    public function getDriverType()
{'fraction_non_alphanumeric': 0.15321252059308071, 'fraction_numerical': 0.0, 'mean_word_length': 2.851704996034893, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 63, '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': '7230978', 'n_tokens_mistral': 1376, 'n_tokens_neox': 1353, 'n_words': 196}