<commit_before><?php namespace Onigoetz\Imagecache\Support\Laravel;

use Illuminate\Http\Request;
use Illuminate\Support\ServiceProvider;
use Onigoetz\Imagecache\Exceptions\InvalidPresetException;
use Onigoetz\Imagecache\Exceptions\NotFoundException;
use Onigoetz\Imagecache\Manager;
use Onigoetz\Imagecache\Transfer;
use Symfony\Component\HttpFoundation\Response;

class ImagecacheServiceProvider extends ServiceProvider
{

    /**
     * Add the namespace to config
     */
    public function registerConfiguration()
    {
        $this->app['config']->package('onigoetz/imagecache', __DIR__ . '/../../config');
    }

    /**
     * Register imagecache
     */
    public function registerManager()
    {
        $this->app['imagecache'] = $this->app->share(
            function () {
                $config = $this->app['config']->get('imagecache::imagecache');

                return new Manager($config);
            }
        );
    }

    public function registerRoute()
    {
        $config = $this->app['config']->get('imagecache::imagecache');

        $url = "{$config['path_images']}/{$config['path_cache']}/{preset}/{file}";

        $this->app['router']->get(
            $url,
            function ($preset, $file) {
                try {
                    $final_file = $this->app['imagecache']->handleRequest($preset, $file);
                } catch (InvalidPresetException $e) {
                    return \Response::make('Invalid preset', 404);
                } catch (NotFoundException $e) {
                    return \Response::make('File not found', 404);
                } catch (\RuntimeException $e) {
                    return \Response::make($e->message(), 500);
                }

                $transfer = new Transfer($final_file);

                $callback = function () use ($transfer) {
                    $transfer->stream();
                };

                return \Response::stream($callback, $transfer->getStatus(), $transfer->getFormattedHeaders());
            }
        )->where('file', '.*');
    }

    /**
     * Register the service provider.
     *
     * @return void
     */
    public function register()
    {
        $this->registerConfiguration();

        $this->registerManager();

        $this->registerRoute();
    }
}
<commit_msg>fixed onigoetz/imagecache#3<commit_after><?php namespace Onigoetz\Imagecache\Support\Laravel;

use Illuminate\Http\Request;
use Illuminate\Support\ServiceProvider;
use Onigoetz\Imagecache\Exceptions\InvalidPresetException;
use Onigoetz\Imagecache\Exceptions\NotFoundException;
use Onigoetz\Imagecache\Manager;
use Onigoetz\Imagecache\Transfer;
use Symfony\Component\HttpFoundation\Response;

class ImagecacheServiceProvider extends ServiceProvider
{

    /**
     * Add the namespace to config
     */
    public function registerConfiguration()
    {
        $this->app['config']->package('onigoetz/imagecache', __DIR__ . '/../../config');
    }

    /**
     * Register imagecache
     */
    public function registerManager()
    {
        $this->app['imagecache'] = $this->app->share(
            function () {
                $config = $this->app['config']->get('imagecache::imagecache');

                return new Manager($config);
            }
        );
    }

    public function registerRoute()
    {
        $config = $this->app['config']->get('imagecache::imagecache');

        $url = "{$config['path_images']}/{$config['path_cache']}/{preset}/{file}";

        $this->app['router']->get(
            $url,
            function ($preset, $file) {
                try {
                    $final_file = $this->app['imagecache']->handleRequest($preset, $file);
                } catch (InvalidPresetException $e) {
                    return \Response::make('Invalid preset', 404);
                } catch (NotFoundException $e) {
                    return \Response::make('File not found', 404);
                } catch (\RuntimeException $e) {
                    return \Response::make($e->message(), 500);
                }

                $transfer = new Transfer($final_file);

                $callback = function () use ($transfer) {
                    $transfer->stream();
                };

                return \Response::stream($callback, $transfer->getStatus(), $transfer->getHeaders());
            }
        )->where('file', '.*');
    }

    /**
     * Register the service provider.
     *
     * @return void
     */
    public function register()
    {
        $this->registerConfiguration();

        $this->registerManager();

        $this->registerRoute();
    }
}

{'fraction_non_alphanumeric': 0.14827660958161717, 'fraction_numerical': 0.004118794710600477, 'mean_word_length': 2.0698602794411176, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 45, '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': '5520156', 'n_tokens_mistral': 1263, 'n_tokens_neox': 1194, 'n_words': 215}