<commit_before><?php

namespace Nord\Lumen\Fractal;

use Illuminate\Contracts\Config\Repository as ConfigRepository;
use Illuminate\Contracts\Container\Container;
use Illuminate\Support\ServiceProvider;
use Laravel\Lumen\Application;
use Nord\Lumen\Fractal\Contracts\FractalService as FractalServiceContract;

class FractalServiceProvider extends ServiceProvider
{

    /**
     * @inheritdoc
     */
    public function register()
    {
        $this->registerContainerBindings($this->app, $this->app['config']);
    }


    /**
     * @param Application|Container $app
     * @param ConfigRepository      $config
     */
    protected function registerContainerBindings(Application $app, ConfigRepository $config)
    {
        $app->configure('fractal');

        $app->singleton(FractalService::class, function () use ($config) {
            $fractal = new FractalService();

            $this->configureService($fractal, $config->get('fractal'));

            return $fractal;
        });

        $app->alias(FractalService::class, FractalServiceContract::class);

        if (!class_exists(FractalService::class)) {
            class_alias(FractalFacade::class, 'Fractal');
        }
    }


    /**
     * @param FractalService $service
     * @param array          $config
     */
    protected function configureService(FractalService $service, array $config)
    {
        if (!empty($config['default_serializer'])) {
            $service->setDefaultSerializer(new $config['default_serializer']);
        }
    }
}
<commit_msg>Refactor FractalServiceProvider<commit_after><?php

namespace Nord\Lumen\Fractal;

use Illuminate\Contracts\Config\Repository as ConfigRepository;
use Illuminate\Contracts\Container\Container;
use Illuminate\Support\ServiceProvider;
use Laravel\Lumen\Application;
use Nord\Lumen\Fractal\Contracts\FractalService as FractalServiceContract;

class FractalServiceProvider extends ServiceProvider
{

    const CONFIG_KEY = 'fractal';

    /**
     * @inheritdoc
     */
    public function register()
    {
        $this->app->configure(self::CONFIG_KEY);

        $this->registerBindings($this->app, $this->app['config']);
        $this->registerFacades();
    }


    /**
     * @param Container        $container
     * @param ConfigRepository $config
     */
    protected function registerBindings(Container $container, ConfigRepository $config)
    {
        $container->singleton(FractalService::class, function () use ($config) {
            $fractal = new FractalService();

            $this->configureService($fractal, $config[self::CONFIG_KEY]);

            return $fractal;
        });

        $container->alias(FractalService::class, FractalServiceContract::class);


    }


    /**
     *
     */
    protected function registerFacades()
    {
        if (!class_exists('Fractal')) {
            class_alias(FractalFacade::class, 'Fractal');
        }
    }


    /**
     * @param FractalService $service
     * @param array          $config
     */
    protected function configureService(FractalService $service, array $config)
    {
        if (!empty($config['default_serializer'])) {
            $service->setDefaultSerializer(new $config['default_serializer']);
        }
    }
}

{'fraction_non_alphanumeric': 0.12380364309972214, 'fraction_numerical': 0.0, 'mean_word_length': 2.960880195599022, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 22, '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': '1660812', 'n_tokens_mistral': 922, 'n_tokens_neox': 911, 'n_words': 154}