FlysystemAzureBlobStorageServiceProvider   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 4
dl 0
loc 30
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A boot() 0 16 2
A register() 0 4 1
1
<?php
2
3
namespace DiamondByBOLD\FlysystemAzureBlobStorage;
4
5
use League\Flysystem\Filesystem;
6
use Illuminate\Support\Facades\Storage;
7
use Illuminate\Support\ServiceProvider;
8
use MicrosoftAzure\Storage\Blob\BlobRestProxy;
9
use League\Flysystem\AzureBlobStorage\AzureBlobStorageAdapter;
10
11
class FlysystemAzureBlobStorageServiceProvider extends ServiceProvider
12
{
13
    /**
14
     * Bootstrap the application services.
15
     */
16
    public function boot()
17
    {
18
        Storage::extend('azure', function ($app, $config) {
19
            $connectionString = sprintf(
20
                'DefaultEndpointsProtocol=%s;AccountName=%s;AccountKey=%s;EndpointSuffix=%s',
21
                isset($config['protocol']) ? $config['protocol'] : 'https',
22
                $config['account']['name'],
23
                $config['account']['key'],
24
                $config['endpoint-suffix']
25
            );
26
27
            $client = BlobRestProxy::createBlobService($connectionString);
28
29
            return new Filesystem(new AzureBlobStorageAdapter($client, $config['container']));
30
        });
31
    }
32
33
    /**
34
     * Register the application services.
35
     */
36
    public function register()
37
    {
38
        $this->mergeConfigFrom(__DIR__.'/../config/filesystems.php', 'filesystems');
39
    }
40
}
41