BaiduBosServiceProvider::boot()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 23
Code Lines 16

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 19
CRAP Score 1

Importance

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