<commit_before><?php
/**
 * @author ChenDasheng
 * @created 2022/2/10 22:27
 */

namespace TrayLabs\InfluxDB\Providers;

use Illuminate\Support\ServiceProvider;
use InfluxDB\Client as InfluxClient;
use InfluxDB\Database as InfluxDB;
use InfluxDB\Driver\UDP;

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

    /**
     * Bootstrap any application services.
     *
     * @return void
     */
    public function boot()
    {
        $path = realpath(__DIR__ . '/../../config/InfluxDB.php');
        $this->mergeConfigFrom($path, 'influxdb');
    }

    /**
     * Register the service provider.
     *
     * @return void
     */
    public function register()
    {
        $this->app->singleton(InfluxDB::class, function ($app) {
            $client = new InfluxClient(
                config('influxdb.host'),
                config('influxdb.port'),
                config('influxdb.username'),
                config('influxdb.password'),
                config('influxdb.ssl'),
                config('influxdb.verifySSL'),
                config('influxdb.timeout')
            );
            if (config('influxdb.udp.enabled') === true) {
                $client->setDriver(new UDP(
                    $client->getHost(),
                    config('influxdb.udp.port')
                ));
            }
            return $client->selectDB(config('influxdb.dbname'));
        });
    }

    /**
     * Get the services provided by the provider.
     *
     * @return array
     */
    public function provides()
    {
        return [
            InfluxDB::class,
        ];
    }
}<commit_msg>Remove code duplication<commit_after><?php

namespace TrayLabs\InfluxDB\Providers;

class LumenServiceProvider extends ServiceProvider
{
    /**
     * Bootstrap any application services.
     *
     * @return void
     */
    public function boot()
    {
        $path = realpath(__DIR__ . '/../../config/InfluxDB.php');
        $this->mergeConfigFrom($path, 'influxdb');
    }
}

{'fraction_non_alphanumeric': 0.1307837582625118, 'fraction_numerical': 0.005193578847969783, 'mean_word_length': 1.8404825737265416, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 10, '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': '916758', 'n_tokens_mistral': 638, 'n_tokens_neox': 602, 'n_words': 119}