Completed
Push — master ( 2399b8...1a55e9 )
by Ramesh
03:21 queued 02:24
created

BackblazeB2ServiceProvider   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 5
c 1
b 0
f 0
lcom 0
cbo 2
dl 0
loc 20
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A boot() 0 14 4
A register() 0 3 1
1
<?php
2
3
namespace Gliterd\BackblazeB2;
4
5
use ChrisWhite\B2\Client as BackblazeClient;
6
use Illuminate\Support\Facades\Storage;
7
use Illuminate\Support\ServiceProvider;
8
use League\Flysystem\Filesystem;
9
use Mhetreramesh\Flysystem\BackblazeAdapter;
10
11
class BackblazeB2ServiceProvider extends ServiceProvider
12
{
13
    public function boot()
14
    {
15
        Storage::extend('b2', function ($app, $config) {
16
            if(!(
17
                isset($config['accountId']) ||
18
                isset($config['applicationKey']) ||
19
                isset($config['bucketName']))) {
20
                throw new BackblazeException('Please set all configuration keys. (accountId, applicationKey, bucketName)');
21
            }
22
            $client = new Client($config['accountId'], $config['applicationKey']);
23
            $adapter = new BackblazeAdapter($client, $config['bucketName']);
24
            return new Filesystem($adapter);
25
        });
26
    }
27
    public function register()
28
    {
29
    }
30
}
31