<commit_before><?php
namespace GuzzleHttp\Subscriber\Log\Support;

use DebugBar\DataCollector\ExceptionsCollector;
use DebugBar\DataCollector\TimeDataCollector;
use DebugBar\DebugBar;
use GuzzleHttp\Client;
use GuzzleHttp\Subscriber\Log\DebugbarSubscriber;
use GuzzleHttp\Subscriber\Log\LogSubscriber;
use Illuminate\Support\ServiceProvider as BaseServiceProvider;
use Psr\Log\LoggerInterface;

class ServiceProvider extends BaseServiceProvider
{
    /**
     * Register method
     */
    public function register()
    {
        $this->registerGuzzleSubscriber();
    }

    /**
     * Register a log subscriber on every Guzzle client.
     */
    private function registerGuzzleSubscriber()
    {
        // Register a log subscriber with every Guzzle client.
        $this->app->bind('GuzzleHttp\Client', function ($app, $params) {
            // Create new client.
            $client = new Client(array_shift($params) ?: []);

            /** @var DebugBar $debugBar */
            $debugBar = $this->app->make('debugbar');

            /** @var LoggerInterface $logger */
            $logger = $debugBar->getCollector('messages');

            /** @var TimeDataCollector $timeline */
            $timeline = $debugBar->getCollector('time');

            /** @var ExceptionsCollector $exceptions */
            $exceptions = $debugBar->getCollector('exceptions');

            // Attach event subscribers.
            $client->getEmitter()->attach(new LogSubscriber($logger));
            $client->getEmitter()->attach(new DebugbarSubscriber($timeline, $exceptions));

            // Return configured client.
            return $client;
        });
    }
}
<commit_msg>Split up functionality in service provider into separate methods<commit_after><?php
namespace GuzzleHttp\Subscriber\Log\Support;

use DebugBar\DataCollector\ExceptionsCollector;
use DebugBar\DataCollector\TimeDataCollector;
use DebugBar\DebugBar;
use GuzzleHttp\Client;
use GuzzleHttp\Subscriber\Log\DebugbarSubscriber;
use GuzzleHttp\Subscriber\Log\LogSubscriber;
use Illuminate\Support\ServiceProvider as BaseServiceProvider;
use Psr\Log\LoggerInterface;

class ServiceProvider extends BaseServiceProvider
{
    /**
     * Register method
     */
    public function register()
    {
        $this->registerGuzzleSubscriber();
    }

    /**
     * Register a log subscriber on every Guzzle client.
     */
    private function registerGuzzleSubscriber()
    {
        // Register a log subscriber with every Guzzle client.
        $this->app->bind('GuzzleHttp\Client', function ($app, $params) {
            // Create new client.
            $client = new Client(array_shift($params) ?: []);

            /** @var DebugBar $debugBar */
            $debugBar = $this->app->make('debugbar');

            $this->registerLogSubsriber($client, $debugBar);
            $this->registerDebugbarSubscriber($client, $debugBar);

            // Return configured client.
            return $client;
        });
    }

    /**
     * @param Client $client
     * @param DebugBar $debugBar
     */
    private function registerLogSubsriber(Client $client, DebugBar $debugBar)
    {
        /** @var LoggerInterface $logger */
        $logger = $debugBar->getCollector('messages');

        // Attach event subscribers.
        $client->getEmitter()->attach(new LogSubscriber($logger));
    }

    /**
     * @param Client $client
     * @param DebugBar $debugBar
     */
    private function registerDebugbarSubscriber(Client $client, DebugBar $debugBar)
    {
        /** @var TimeDataCollector $timeline */
        $timeline = $debugBar->getCollector('time');

        /** @var ExceptionsCollector $exceptions */
        $exceptions = $debugBar->getCollector('exceptions');

        // Attach event subscribers.
        $client->getEmitter()->attach(new DebugbarSubscriber($timeline, $exceptions));
    }
}

{'fraction_non_alphanumeric': 0.12048503611971104, 'fraction_numerical': 0.0, 'mean_word_length': 2.749516441005803, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 29, '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': '3722578', 'n_tokens_mistral': 1077, 'n_tokens_neox': 1040, 'n_words': 225}