<commit_before><?php namespace Bkwld\EloquentUploads;

// Deps
use Illuminate\Support\ServiceProvider as LaravelServiceProvider;
use League\Flysystem\Adapter\Local as LocalAdapter;
use League\Flysystem\Filesystem;
use League\Flysystem\MountManager;

class ServiceProvider extends LaravelServiceProvider {

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

	/**
	 * Bootstrap the application events.
	 *
	 * @return void
	 */
	public function boot() {

		// Listen for Eloquent saving and deleting
		$this->app['events']->listen('eloquent.saving:*', 'eloquent_uploads.observer@onSaving');
		$this->app['events']->listen('eloquent.deleting:*', 'eloquent_uploads.observer@onDeleting');

	}

	/**
	 * Register the service provider.
	 *
	 * @return void
	 */
	public function register() {

		// Instantiate Flysystem for this package
		$this->app->bind('eloquent_uploads.flysystem_manager', function($app) {

			// Get the temp directory, this is where uploads will be moved from
			$tmp = ini_get('upload_tmp_dir') ?: sys_get_temp_dir();

			// Get the dst directory from the config
			$dst = public_path().'/uploads';

			// Create the MountManger instance
			return new MountManager([
				'tmp' => new Filesystem(new LocalAdapter($tmp)),
				'dst' => new Filesystem(new LocalAdapter($dst)),
			]);
		});

		// Instantiate observer
		$this->app->bind('eloquent_uploads.observer', function($app) {
			return new Observer($app['request'], $app['eloquent_uploads.storage']);
		});

		// Instantiate storage class
		$this->app->bind('eloquent_uploads.storage', function($app) {
			return new Storage($app['eloquent_uploads.flysystem_manager']);
		});

	}

	/**
	 * Get the services provided by the provider.
	 *
	 * @return array
	 */
	public function provides() {
		return array(
			'eloquent_uploads.flysystem_manager',
			'eloquent_uploads.observer',
			'eloquent_uploads.storage',
		);
	}

}<commit_msg>Breaking the destination disk in to it's own IoC type<commit_after><?php namespace Bkwld\EloquentUploads;

// Deps
use Illuminate\Support\ServiceProvider as LaravelServiceProvider;
use League\Flysystem\Adapter\Local as LocalAdapter;
use League\Flysystem\Filesystem;
use League\Flysystem\MountManager;

class ServiceProvider extends LaravelServiceProvider {

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

	/**
	 * Bootstrap the application events.
	 *
	 * @return void
	 */
	public function boot() {

		// Listen for Eloquent saving and deleting
		$this->app['events']->listen('eloquent.saving:*', 'eloquent_uploads.observer@onSaving');
		$this->app['events']->listen('eloquent.deleting:*', 'eloquent_uploads.observer@onDeleting');

	}

	/**
	 * Register the service provider.
	 *
	 * @return void
	 */
	public function register() {

		// Instantiate the disk for the destination
		$this->app->bind('eloquent_uploads.dst', function($app) {
			return new Filesystem(new LocalAdapter(public_path().'/uploads'));
		});

		// Instantiate Flysystem for this package
		$this->app->bind('eloquent_uploads.manager', function($app) {

			// Get the temp directory, this is where uploads will be moved from
			$tmp = ini_get('upload_tmp_dir') ?: sys_get_temp_dir();

			// Create the MountManger instance
			return new MountManager([
				'tmp' => new Filesystem(new LocalAdapter($tmp)),
				'dst' => $app['eloquent_uploads.dst'],
			]);
		});

		// Instantiate observer
		$this->app->bind('eloquent_uploads.observer', function($app) {
			return new Observer($app['request'], $app['eloquent_uploads.storage']);
		});

		// Instantiate storage class
		$this->app->bind('eloquent_uploads.storage', function($app) {
			return new Storage($app['eloquent_uploads.manger']);
		});

	}

	/**
	 * Get the services provided by the provider.
	 *
	 * @return array
	 */
	public function provides() {
		return array(
			'eloquent_uploads.dst',
			'eloquent_uploads.manger',
			'eloquent_uploads.observer',
			'eloquent_uploads.storage',
		);
	}

}
{'fraction_non_alphanumeric': 0.1410921670373116, 'fraction_numerical': 0.0, 'mean_word_length': 4.137055837563452, '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': '4033679', 'n_tokens_mistral': 1437, 'n_tokens_neox': 1229, 'n_words': 291}