Skip to content
This repository has been archived by the owner on Mar 24, 2024. It is now read-only.

Commit

Permalink
Tidied up service provider a bit
Browse files Browse the repository at this point in the history
  • Loading branch information
matthewbdaly committed Nov 15, 2020
1 parent 628fe40 commit 20f109a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
12 changes: 4 additions & 8 deletions src/AzureStorageServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,10 @@
use League\Flysystem\Filesystem;
use League\Flysystem\Cached\CachedAdapter;
use League\Flysystem\Cached\Storage\Memory as MemoryStore;
use Matthewbdaly\LaravelAzureStorage\Exceptions\CacheAdapterNotInstalled;
use MicrosoftAzure\Storage\Blob\BlobRestProxy;
use MicrosoftAzure\Storage\Common\Middlewares\RetryMiddleware;
use MicrosoftAzure\Storage\Common\Middlewares\RetryMiddlewareFactory;
use RuntimeException;
use Throwable;

/**
* Service provider for Azure Blob Storage
Expand All @@ -38,12 +37,9 @@ public function boot()
$config['prefix'] ?? null
);

$cache = Arr::pull($config, 'cache');
if ($cache) {
try {
class_exists(CachedAdapter::class);
} catch (Throwable $e) {
throw new RuntimeException("Caching requires the league/flysystem-cached-adapter to be installed.");
if ($cache = Arr::pull($config, 'cache')) {
if (!class_exists(CachedAdapter::class)) {
throw new CacheAdapterNotInstalled("Caching requires the league/flysystem-cached-adapter to be installed.");
}

$adapter = new CachedAdapter($adapter, $this->createCacheStore($cache));
Expand Down
10 changes: 10 additions & 0 deletions src/Exceptions/CacheAdapterNotInstalled.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

namespace Matthewbdaly\LaravelAzureStorage\Exceptions;

/**
* Invalid custom URL
*/
final class CacheAdapterNotInstalled extends \Exception
{
}

0 comments on commit 20f109a

Please sign in to comment.