Passed
Push — master ( 7750a9...bbeaff )
by xiaohui
03:36
created

WantuFileServiceProvider::boot()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 16
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 10
nc 1
nop 0
dl 0
loc 16
rs 9.9332
c 1
b 0
f 0
1
<?php
2
3
namespace XiaohuiLam\LaravelFilesystem\Wantu;
4
5
use League\Flysystem\Config;
6
use League\Flysystem\Filesystem;
7
use Illuminate\Support\ServiceProvider;
8
use XiaohuiLam\LaravelFilesystem\Wantu\Plugins\GetUrl;
9
use XiaohuiLam\LaravelFilesystem\Wantu\Plugins\UploadToken;
10
11
class WantuFileServiceProvider extends ServiceProvider
12
{
13
    public function register()
14
    {
15
        app('filesystem')->extend('wantu', function ($app, $config) {
16
            $adapter = new WantuFileAdapter(
17
                $config['access_key'],
18
                $config['secret_key'],
19
                $config['namespace'],
20
                $config['domain']
21
            );
22
            $flysystem = new Filesystem($adapter, new Config(['disable_asserts' => true]));
23
            // $flysystem->addPlugin(new FetchFile());
24
            $flysystem->addPlugin(new UploadToken());
25
            $flysystem->addPlugin(new GetUrl());
26
            // $flysystem->addPlugin(new PrivateDownloadUrl());
27
            // $flysystem->addPlugin(new RefreshFile());
28
            return $flysystem;
29
        });
30
    }
31
}
32