UpyunServiceProvider::boot()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 15

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 15
rs 9.7666
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
namespace JellyBool\Flysystem\Upyun;
4
5
use League\Flysystem\Filesystem;
6
use Illuminate\Support\Facades\Storage;
7
use Illuminate\Support\ServiceProvider;
8
use JellyBool\Flysystem\Upyun\Plugins\ImagePreviewUrl;
9
10
class UpyunServiceProvider extends ServiceProvider
11
{
12
    /**
13
     * Bootstrap the application services.
14
     *
15
     * @return void
16
     */
17
    public function boot()
18
    {
19
        Storage::extend('upyun', function ($app, $config) {
20
            $adapter = new UpyunAdapter(
21
                $config['bucket'], $config['operator'],
22
                $config['password'],$config['domain'],$config['protocol']
23
            );
24
25
            $filesystem = new Filesystem($adapter);
26
27
            $filesystem->addPlugin(new ImagePreviewUrl());
28
29
            return $filesystem;
30
        });
31
    }
32
33
    /**
34
     * Register the application services.
35
     *
36
     * @return void
37
     */
38
    public function register()
39
    {
40
        //
41
    }
42
}
43