Completed
Push — master ( ed7b36...2724c6 )
by Thomas
09:10
created

BaiduBosServiceProvider::boot()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 20
Code Lines 14

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 14
c 1
b 0
f 0
dl 0
loc 20
rs 9.7998
cc 1
nc 1
nop 0
1
<?php
2
3
namespace Sulao\LaravelFilesystem\BaiduBos;
4
5
use Illuminate\Support\Facades\Storage;
6
use Illuminate\Support\ServiceProvider;
7
use League\Flysystem\Filesystem;
8
use Sulao\BaiduBos\Client;
9
use Sulao\Flysystem\BaiduBos\BaiduBosAdapter;
10
11
class BaiduBosServiceProvider extends ServiceProvider
12
{
13
    /**
14
     * Bootstrap any application services.
15
     *
16
     * @return void
17
     */
18
    public function boot()
19
    {
20
        Storage::extend('bos', function ($app, $config) {
21
            $config += [
22
                'disable_asserts' => true,
23
                'case_sensitive' => true,
24
                'options' => [],
25
            ];
26
27
            $client = new Client([
28
                'access_key' => $config['access_key'],
29
                'secret_key' => $config['secret_key'],
30
                'bucket' => $config['bucket'],
31
                'region' => $config['region'],
32
                'options' => $config['options']
33
            ]);
34
35
            return new Filesystem(new BaiduBosAdapter($client), [
36
                'disable_asserts' => $config['disable_asserts'],
37
                'case_sensitive' => $config['case_sensitive'],
38
            ]);
39
        });
40
    }
41
42
    /**
43
     * Register the service provider.
44
     *
45
     * @return void
46
     */
47
    public function register()
48
    {
49
    }
50
}
51